mcfly/packages/cli/commands/new.mjs
Ayo Ayco 56592bdeef
test(cli): add tests for cli commands (#37)
* chore(cli): add vitest & add test script

* chore: add test:cli script

* test(cli): initial tests for build command

* chore(cli): add nitropack as devDepencency for tests

* chore(cli): add vitest config

* test(cli): add tests for build command

* test(cli): add tests for new command
2024-12-07 02:44:38 +01:00

43 lines
No EOL
910 B
JavaScript

#!/usr/bin/env node
import { execSync } from "node:child_process";
import { consola } from "consola";
import { defineCommand } from "citty";
function createNew(args) {
const directory = args.dir || args._dir;
const command = directory
? `npm create mcfly@latest ${directory}`
: "npm create mcfly@latest";
try {
execSync(command, { stdio: "inherit" });
} catch (e) {
consola.error(e);
}
}
export default defineCommand({
meta: {
name: "prepare",
description: "Creates a new McFly project.",
},
args: {
dir: {
type: "string",
description: "project root directory",
required: false,
},
_dir: {
type: "positional",
description: "project root directory (prefer using `--dir`)",
required: false,
},
},
async run({ args }) {
createNew(args)
},
});
export const exportedForTest = {
createNew
}