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 { downloadTemplate } = require("giget");
|
||||||
const { execSync: exec } = require("node:child_process");
|
const { execSync: exec } = require("node:child_process");
|
||||||
|
|
||||||
|
const [, , directoryArg] = process.argv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{
|
* @typedef {{
|
||||||
* prompt: string,
|
* prompt: string,
|
||||||
|
@ -21,10 +23,16 @@ async function create() {
|
||||||
console.clear();
|
console.clear();
|
||||||
const defaultDirectory = "./mcfly-app";
|
const defaultDirectory = "./mcfly-app";
|
||||||
consola.box(`👋 Hello! Welcome to ${colorize("bold", "McFly")}!`);
|
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:", {
|
(await consola.prompt("Give your new project a name:", {
|
||||||
placeholder: defaultDirectory,
|
placeholder: defaultDirectory,
|
||||||
})) ?? defaultDirectory;
|
})) ?? defaultDirectory;
|
||||||
|
} else {
|
||||||
|
consola.success(`Using ${directory} as name.`);
|
||||||
|
}
|
||||||
|
|
||||||
const hasErrors = await downloadTemplateToDirectory(directory);
|
const hasErrors = await downloadTemplateToDirectory(directory);
|
||||||
const safeDirectory = getSafeDirectory(directory);
|
const safeDirectory = getSafeDirectory(directory);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "create-mcfly",
|
"name": "create-mcfly",
|
||||||
"version": "0.3.0",
|
"version": "0.3.1",
|
||||||
"bin": {
|
"bin": {
|
||||||
"create-mcfly": "./index.js"
|
"create-mcfly": "./index.js"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue