From 5a3193f5f6f9e8baa6cf6f24491df02d1e031d69 Mon Sep 17 00:00:00 2001 From: player31-kks Date: Mon, 1 Jan 2024 11:07:03 +0900 Subject: [PATCH] refactor: new command --- src/commands/new.ts | 6 ++++-- src/tools/process.ts | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/tools/process.ts diff --git a/src/commands/new.ts b/src/commands/new.ts index 7cccd5e..d2ba30a 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -1,6 +1,7 @@ import { GluegunFilesystem, GluegunPrompt, GluegunSystem, GluegunToolbox } from 'gluegun'; import { error, p, prefix, startSpinner, stopSpinner, warning } from '../tools/pretty'; import { copyBoilerplate } from '../tools/filesystem'; +import { cd, exit } from '../tools/process'; const isWindows = process.platform === 'win32'; @@ -12,6 +13,7 @@ module.exports = { run: async (toolbox: GluegunToolbox) => { const { parameters, meta, prompt, filesystem, system } = toolbox; const { path } = filesystem; + const userInputName = parameters.first; const rootPath = path(`${meta.src}`, '..'); const boilerplatePath = path(rootPath, 'boilerplate'); @@ -30,10 +32,10 @@ module.exports = { excluded: ['.vscode', 'node_modules', 'yarn.lock', 'bun.lockb', 'package-lock.json'], }); - process.chdir(targetPath); + cd(targetPath); changePackageJsonName(packageName, filesystem); gitInit(system); - process.exit(0); + exit(); }, }; diff --git a/src/tools/process.ts b/src/tools/process.ts new file mode 100644 index 0000000..c541ae0 --- /dev/null +++ b/src/tools/process.ts @@ -0,0 +1,6 @@ +export const cd = (path: string) => { + process.chdir(path); +}; +export const exit = () => { + process.exit(0); +};