-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add select-node, select-compiler commands
- Loading branch information
Showing
7 changed files
with
172 additions
and
15 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
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,28 @@ | ||
import envPaths from 'env-paths'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
|
||
const configPath = path.resolve(envPaths('aecli').config, 'config.json'); | ||
const options = ['url', 'compilerUrl']; | ||
|
||
async function readConfig() { | ||
try { | ||
return await fs.readJson(configPath); | ||
} catch { | ||
return {}; | ||
} | ||
} | ||
|
||
export async function addToConfig(configPart) { | ||
await fs.outputJson(configPath, { ...await readConfig(), ...configPart }); | ||
} | ||
|
||
const configPromise = readConfig(); | ||
|
||
export async function setCommandOptions(program) { | ||
const config = await configPromise; | ||
options | ||
.filter((option) => option in config) | ||
.forEach((option) => program.setOptionValueWithSource(option, config[option], 'config')); | ||
program.commands.forEach(setCommandOptions); | ||
} |
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