fix(cli): new command no args
This commit is contained in:
parent
d7297f6b3f
commit
a4dd2d0549
1 changed files with 15 additions and 4 deletions
|
@ -3,7 +3,6 @@
|
||||||
import { execSync as exec } from "node:child_process";
|
import { execSync as exec } from "node:child_process";
|
||||||
import { consola } from "consola";
|
import { consola } from "consola";
|
||||||
import { defineCommand } from "citty";
|
import { defineCommand } from "citty";
|
||||||
import { commonArgs } from "../common.mjs";
|
|
||||||
|
|
||||||
export default defineCommand({
|
export default defineCommand({
|
||||||
meta: {
|
meta: {
|
||||||
|
@ -11,12 +10,24 @@ export default defineCommand({
|
||||||
description: "Creates a new McFly project.",
|
description: "Creates a new McFly project.",
|
||||||
},
|
},
|
||||||
args: {
|
args: {
|
||||||
...commonArgs,
|
dir: {
|
||||||
|
type: "string",
|
||||||
|
description: "project root directory",
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
_dir: {
|
||||||
|
type: "positional",
|
||||||
|
description: "project root directory (prefer using `--dir`)",
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
async run({ args }) {
|
async run({ args }) {
|
||||||
const [directory] = args._;
|
const directory = args.dir || args._dir;
|
||||||
|
const command = directory
|
||||||
|
? `npm create mcfly@latest ${directory}`
|
||||||
|
: "npm create mcfly@latest";
|
||||||
try {
|
try {
|
||||||
exec(`npm create mcfly@latest ${directory ?? ""}`, { stdio: "inherit" });
|
exec(command, { stdio: "inherit" });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
consola.error(e);
|
consola.error(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue