@corva/create-app 0.45.0-1 → 0.45.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/main.js +22 -7
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -250,15 +250,15 @@ export async function run() {
|
|
|
250
250
|
try {
|
|
251
251
|
await program.parseAsync(process.argv);
|
|
252
252
|
} catch (e) {
|
|
253
|
-
handleError(e);
|
|
253
|
+
handleError(program, e);
|
|
254
254
|
|
|
255
255
|
process.exit(1);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
const handleError = (e) => {
|
|
259
|
+
const handleError = (program, e) => {
|
|
260
260
|
if (e instanceof CommanderError) {
|
|
261
|
-
handleCommanderError(e);
|
|
261
|
+
handleCommanderError(program, e);
|
|
262
262
|
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
@@ -275,7 +275,7 @@ const handleError = (e) => {
|
|
|
275
275
|
e.cause && console.error(chalk.red(e.cause));
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
-
const handleCommanderError = (e) => {
|
|
278
|
+
const handleCommanderError = (program, e) => {
|
|
279
279
|
switch (e.code) {
|
|
280
280
|
case 'commander.missingArgument': {
|
|
281
281
|
const match = /error:.*'(.*)'/.exec(e.message);
|
|
@@ -347,11 +347,26 @@ async function initPackage(projectName, opts) {
|
|
|
347
347
|
|
|
348
348
|
logger.log(`Creating a new Corva app in ${chalk.green(root)}.`);
|
|
349
349
|
|
|
350
|
-
|
|
351
|
-
|
|
350
|
+
await fs.ensureDir(root);
|
|
351
|
+
|
|
352
|
+
if ((await fs.readdir(root)).length) {
|
|
353
|
+
const shouldCleanup = await inquirer
|
|
354
|
+
.prompt([
|
|
355
|
+
{
|
|
356
|
+
message: `Directory "${root}" is not empty. Clean it to proceed?`,
|
|
357
|
+
name: 'cleanup',
|
|
358
|
+
type: 'confirm',
|
|
359
|
+
},
|
|
360
|
+
])
|
|
361
|
+
.then(_.get('cleanup'));
|
|
362
|
+
|
|
363
|
+
if (shouldCleanup) {
|
|
364
|
+
await fs.emptyDir(root);
|
|
365
|
+
} else {
|
|
366
|
+
throw new Error(`Directory is not empty: ${root}`);
|
|
367
|
+
}
|
|
352
368
|
}
|
|
353
369
|
|
|
354
|
-
await fs.mkdir(root);
|
|
355
370
|
await fs.writeJSON(path.join(root, 'manifest.json'), manifest.manifest, writejsonOptions);
|
|
356
371
|
|
|
357
372
|
await addTemplate(root, manifest, runtime);
|