-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output API warnings in the console (#119)
* Output API warnings in the console * Bump patch version * Add missing import * Don't use ES2020 features ESLint does not like them
- Loading branch information
1 parent
889bdac
commit 5e6aaaf
Showing
5 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const logWarnings = res => { | ||
const warnings = res && res.extensions && res.extensions.warnings; | ||
if (!warnings || !Array.isArray(warnings)) return res; | ||
|
||
warnings.forEach(warning => { | ||
if (!warning || !warning.message) return; | ||
|
||
try { | ||
const locations = | ||
warning.locations && warning.locations.map(loc => `line ${loc.line}, column ${loc.column}`).join("; "); | ||
const path = warning.path && warning.path.join(" → "); | ||
|
||
let message = warning.message; | ||
|
||
// remove the dot at the end of the message | ||
message = message.replace(/\.$/, ""); | ||
// start the message with lower case letter | ||
message = message.charAt(0).toLowerCase() + message.slice(1); | ||
|
||
const messageParts = [ | ||
"[monday API]", | ||
`${path}:`, | ||
message, | ||
locations && `@ ${locations}`, | ||
warning.extensions ? ["\n\nAdditional details:", warning.extensions] : undefined | ||
] | ||
.flat() | ||
.filter(Boolean); | ||
|
||
console.warn(...messageParts); | ||
} catch (e) { | ||
if (warning) { | ||
console.warn("[monday API] Warning:", warning); | ||
} | ||
} | ||
}); | ||
|
||
return res; | ||
}; | ||
|
||
module.exports = { | ||
logWarnings | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters