feat(create-mcfly): accept project name as argument
This commit is contained in:
parent
24ffd3f9e2
commit
82d4131b7e
2 changed files with 13 additions and 5 deletions
|
@ -5,6 +5,8 @@ const { colorize } = require("consola/utils");
|
|||
const { downloadTemplate } = require("giget");
|
||||
const { execSync: exec } = require("node:child_process");
|
||||
|
||||
const [, , directoryArg] = process.argv;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* prompt: string,
|
||||
|
@ -21,10 +23,16 @@ async function create() {
|
|||
console.clear();
|
||||
const defaultDirectory = "./mcfly-app";
|
||||
consola.box(`👋 Hello! Welcome to ${colorize("bold", "McFly")}!`);
|
||||
const directory =
|
||||
let directory = directoryArg;
|
||||
|
||||
if (!directory) {
|
||||
directory =
|
||||
(await consola.prompt("Give your new project a name:", {
|
||||
placeholder: defaultDirectory,
|
||||
})) ?? defaultDirectory;
|
||||
} else {
|
||||
consola.success(`Using ${directory} as name.`);
|
||||
}
|
||||
|
||||
const hasErrors = await downloadTemplateToDirectory(directory);
|
||||
const safeDirectory = getSafeDirectory(directory);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "create-mcfly",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"bin": {
|
||||
"create-mcfly": "./index.js"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue