Skip to content

Commit da9b1e8

Browse files
committed
fix: cmd
1 parent 4aa318b commit da9b1e8

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/cmd.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
3030
return
3131
}
3232
log(config, LogLevel.info, `Simple Scaffold v${pkg.version}`)
33-
const tmpPath = generateUniqueTmpPath()
33+
config.tmpDir = generateUniqueTmpPath()
3434
try {
3535
log(config, LogLevel.debug, "Parsing config file...", config)
36-
const parsed = await parseConfigFile(config, tmpPath)
36+
const parsed = await parseConfigFile(config)
3737
await Scaffold(parsed)
3838
} catch (e) {
3939
const message = "message" in (e as any) ? (e as any).message : e?.toString()
4040
log(config, LogLevel.error, message)
4141
} finally {
42-
log(config, LogLevel.debug, "Cleaning up temporary files...", tmpPath)
43-
await fs.rm(tmpPath, { recursive: true, force: true })
42+
log(config, LogLevel.debug, "Cleaning up temporary files...", config.tmpDir)
43+
await fs.rm(config.tmpDir, { recursive: true, force: true })
4444
}
4545
})
4646
.option({
@@ -171,7 +171,6 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
171171
aliases: ["ls"],
172172
description: "List all available templates for a given config. See `list -h` for more information.",
173173
run: async (_config) => {
174-
const tmpPath = generateUniqueTmpPath()
175174
const config = {
176175
templates: [],
177176
name: "",
@@ -180,19 +179,20 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
180179
subdir: false,
181180
overwrite: false,
182181
dryRun: false,
182+
tmpDir: generateUniqueTmpPath(),
183183
..._config,
184184
config: _config.config ?? (!_config.git ? process.cwd() : undefined),
185185
}
186186
try {
187-
const file = await getConfigFile(config, tmpPath)
187+
const file = await getConfigFile(config)
188188
console.log(colorize.underline`Available templates:\n`)
189189
console.log(Object.keys(file).join("\n"))
190190
} catch (e) {
191191
const message = "message" in (e as any) ? (e as any).message : e?.toString()
192192
log(config, LogLevel.error, message)
193193
} finally {
194-
log(config, LogLevel.debug, "Cleaning up temporary files...", tmpPath)
195-
await fs.rm(tmpPath, { recursive: true, force: true })
194+
log(config, LogLevel.debug, "Cleaning up temporary files...", config.tmpDir)
195+
await fs.rm(config.tmpDir, { recursive: true, force: true })
196196
}
197197
},
198198
})

0 commit comments

Comments
 (0)