diff options
Diffstat (limited to 'scripts/create.js')
-rw-r--r-- | scripts/create.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/create.js b/scripts/create.js index 0e785fa..184dc70 100644 --- a/scripts/create.js +++ b/scripts/create.js | |||
@@ -14,14 +14,19 @@ You can set "Folder name" to "FerdiDev" to use Ferdi's development instance inst | |||
14 | 14 | ||
15 | pnpm run create WhatsApp FerdiDev | 15 | pnpm run create WhatsApp FerdiDev |
16 | `); | 16 | `); |
17 | return; | 17 | throw new Error('Please provide the correct number of args!'); |
18 | } | 18 | } |
19 | 19 | ||
20 | const recipeName = process.argv[2]; | 20 | const recipeName = process.argv[2]; |
21 | const recipe = recipeName.toLowerCase().replace(/\s/g, '-'); | 21 | const recipe = recipeName.toLowerCase().replace(/\s/g, '-'); |
22 | const cleanRecipeId = recipe.replace(/[^a-z]/g, ''); // Clean recipe ID only containing a-z, for usage as the JavaScript class name | 22 | const cleanRecipeId = recipe.replace(/[^a-z]/g, ''); // Clean recipe ID only containing a-z, for usage as the JavaScript class name |
23 | const folderName = process.argv[3] || 'Ferdi'; | 23 | const folderName = process.argv[3] || 'Ferdi'; |
24 | const filesThatNeedTextReplace = ['package.json', 'index.js', 'webview.js', 'README.md']; | 24 | const filesThatNeedTextReplace = [ |
25 | 'package.json', | ||
26 | 'index.js', | ||
27 | 'webview.js', | ||
28 | 'README.md', | ||
29 | ]; | ||
25 | 30 | ||
26 | (async () => { | 31 | (async () => { |
27 | // Folder paths | 32 | // Folder paths |
@@ -36,7 +41,7 @@ const filesThatNeedTextReplace = ['package.json', 'index.js', 'webview.js', 'REA | |||
36 | const sampleRecipe = path.join(__dirname, 'sample_recipe'); | 41 | const sampleRecipe = path.join(__dirname, 'sample_recipe'); |
37 | 42 | ||
38 | // Make sure dev recipe folder exists | 43 | // Make sure dev recipe folder exists |
39 | if (!(await fs.exists(recipesFolder))) { | 44 | if (!fs.existsSync(recipesFolder)) { |
40 | console.log( | 45 | console.log( |
41 | `Couldn't find your recipe folder (${recipesFolder}). Is Ferdi installed?`, | 46 | `Couldn't find your recipe folder (${recipesFolder}). Is Ferdi installed?`, |
42 | ); | 47 | ); |
@@ -44,7 +49,7 @@ const filesThatNeedTextReplace = ['package.json', 'index.js', 'webview.js', 'REA | |||
44 | } | 49 | } |
45 | await fs.ensureDir(devRecipeFolder); | 50 | await fs.ensureDir(devRecipeFolder); |
46 | 51 | ||
47 | if (await fs.exists(newRecipeFolder)) { | 52 | if (fs.existsSync(newRecipeFolder)) { |
48 | console.log('⚠️ Recipe already exists'); | 53 | console.log('⚠️ Recipe already exists'); |
49 | return; | 54 | return; |
50 | } | 55 | } |