feat(create-mcfly): accept project name as argument

This commit is contained in:
Ayo 2023-10-25 21:51:14 +02:00
parent 24ffd3f9e2
commit 82d4131b7e
2 changed files with 13 additions and 5 deletions

View file

@ -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);

View file

@ -1,6 +1,6 @@
{
"name": "create-mcfly",
"version": "0.3.0",
"version": "0.3.1",
"bin": {
"create-mcfly": "./index.js"
},