Skip to content

Commit

Permalink
refactor: new command
Browse files Browse the repository at this point in the history
  • Loading branch information
player31-kks committed Jan 1, 2024
1 parent 572ea6a commit 5a3193f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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');
Expand All @@ -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();
},
};

Expand Down
6 changes: 6 additions & 0 deletions src/tools/process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const cd = (path: string) => {
process.chdir(path);
};
export const exit = () => {
process.exit(0);
};

0 comments on commit 5a3193f

Please sign in to comment.