@corva/create-app 0.45.0-2 → 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 +18 -3
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -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);
|