-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for
config
export (#133)
* feat: add support for `config` export * refactor: add collector file * refactor: use file URL * feat: add exit codes * fix: pass logger * chore: setup Deno in integration workflow * refactor: move config extractor to separate file * feat: print stdout * refactor: run config after bundling * chore: add comments * chore: improve tests
- Loading branch information
1 parent
71db0a4
commit adb4f82
Showing
18 changed files
with
481 additions
and
55 deletions.
There are no files selected for viewing
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,38 @@ | ||
const [functionURL, collectorURL, rawExitCodes] = Deno.args | ||
const exitCodes = JSON.parse(rawExitCodes) | ||
|
||
let func | ||
|
||
try { | ||
func = await import(functionURL) | ||
} catch { | ||
Deno.exit(exitCodes.ImportError) | ||
} | ||
|
||
if (func.config === undefined) { | ||
Deno.exit(exitCodes.NoConfig) | ||
} | ||
|
||
if (typeof func.config !== 'function') { | ||
Deno.exit(exitCodes.InvalidExport) | ||
} | ||
|
||
let config | ||
|
||
try { | ||
config = await func.config() | ||
} catch (error) { | ||
console.error(error) | ||
|
||
Deno.exit(exitCodes.RuntimeError) | ||
} | ||
|
||
try { | ||
const result = JSON.stringify(config) | ||
|
||
await Deno.writeTextFile(new URL(collectorURL), result) | ||
} catch { | ||
Deno.exit(exitCodes.SerializationError) | ||
} | ||
|
||
Deno.exit(exitCodes.Success) |
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
Oops, something went wrong.