Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit cec1857

Browse files
committed
Update lib/create.js
1 parent 1e09970 commit cec1857

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/create.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ async function create(name, options) {
8181
await outputDev(`Project type: ${projectType}`);
8282
await outputDev(`Project type super: ${projectTypeSuper}`);
8383
const load = require("io-spin");
84-
const spinner = load("Creating project");
84+
// close spin if dev
85+
outputDev("Spinners are disabled in dev mode");
86+
const spinner = fs.pathExistsSync(path.join(process.cwd(), "ondev.key")) ? {
87+
start: () => 0,
88+
stop: () => 0,
89+
update: () => 0
90+
} : load("Creating project");
8591
// start time
8692
const startTime = new Date().getTime();
8793
spinner.start();
@@ -91,10 +97,17 @@ async function create(name, options) {
9197
await outputDev("Remove fastjs_cli_create");
9298
fs.removeSync(path.join(runPath, "fastjs_cli_create"));
9399
}
100+
// check npm version to number
101+
const npmVersion = require("child_process").execSync("npm -v").toString()
102+
const npmVersionNum = Number(npmVersion.split(".")[0])
103+
await outputDev(`npm version: ${npmVersionNum}`);
104+
// if npm version >= 7
105+
const EXTRA_ARGS = npmVersionNum >= 7 ? "-- " : "";
106+
await outputDev(`EXTRA_ARGS: ${EXTRA_ARGS}`);
94107
// do create command
95108
const {exec} = require('child_process');
96109
spinner.update("Install template");
97-
exec(`npm create vite@latest fastjs_cli_create -- --template ${projectType}`, {cwd: runPath}, error => {
110+
exec(`npm create vite@latest fastjs_cli_create ${EXTRA_ARGS} --template ${projectType}`, {cwd: runPath}, error => {
98111
if (error) {
99112
spinner.stop();
100113
outputDev(error);

0 commit comments

Comments
 (0)