fix: try to await scaffold before finally

This commit is contained in:
2024-02-04 00:08:04 +02:00
committed by Chen Asraf
parent 43c9e8748f
commit 1b70897f98

View File

@@ -29,10 +29,12 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
} }
log(config, LogLevel.info, `Simple Scaffold v${pkg.version}`) log(config, LogLevel.info, `Simple Scaffold v${pkg.version}`)
const tmpPath = path.resolve(os.tmpdir(), `scaffold-config-${Date.now()}`) const tmpPath = path.resolve(os.tmpdir(), `scaffold-config-${Date.now()}`)
const parsed = await parseConfigFile(config, tmpPath)
try { try {
return Scaffold(parsed) log(config, LogLevel.debug, "Parsing config file...", config)
const parsed = await parseConfigFile(config, tmpPath)
await Scaffold(parsed)
} finally { } finally {
log(config, LogLevel.debug, "Cleaning up temporary files...", tmpPath)
await fs.rm(tmpPath, { recursive: true, force: true }) await fs.rm(tmpPath, { recursive: true, force: true })
} }
}) })
@@ -133,7 +135,13 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
"Determine amount of logs to display. The values are: " + "Determine amount of logs to display. The values are: " +
`${chalk.bold`\`none | debug | info | warn | error\``}. ` + `${chalk.bold`\`none | debug | info | warn | error\``}. ` +
"The provided level will display messages of the same level or higher.", "The provided level will display messages of the same level or higher.",
parse: (v) => v.toLowerCase(), parse: (v) => {
const val = v.toLowerCase()
if (!(val in LogLevel)) {
throw new Error(`Invalid log level: ${val}, must be one of: ${Object.keys(LogLevel).join(", ")}`)
}
return val
},
}) })
.flag({ .flag({
name: "dry-run", name: "dry-run",