@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.
Files changed (2) hide show
  1. package/lib/main.js +18 -3
  2. 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
- if (fs.existsSync(root)) {
351
- throw new Error(`Directory already exists: ${root}`);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.45.0-2",
3
+ "version": "0.45.0-3",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [