diff options
Diffstat (limited to 'scripts/load.js')
-rw-r--r-- | scripts/load.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/load.js b/scripts/load.js new file mode 100644 index 0000000..3c11240 --- /dev/null +++ b/scripts/load.js | |||
@@ -0,0 +1,39 @@ | |||
1 | /** | ||
2 | * Load recipe into development folder | ||
3 | */ | ||
4 | const fs = require('fs-extra'); | ||
5 | const path = require('path'); | ||
6 | |||
7 | console.log('load: Load recipe into development folder'); | ||
8 | console.log('This command will empty the recipe_src folder. Please make sure that there are no important files in that directory.'); | ||
9 | |||
10 | const recipe = process.argv[2]; | ||
11 | if (!recipe) { | ||
12 | console.log('Usage: yarn load [recipe]'); | ||
13 | return; | ||
14 | } | ||
15 | |||
16 | console.log(`Loading ${recipe}`); | ||
17 | |||
18 | // Create paths to important files | ||
19 | const recipeSrc = path.join(__dirname, 'recipe_src'); | ||
20 | const recipePkg = path.join(__dirname, '../', 'uncompressed', recipe); | ||
21 | |||
22 | // Let us work in an async environment | ||
23 | (async () => { | ||
24 | // Check that recipe folder exists | ||
25 | if (!await fs.pathExists(recipePkg)) { | ||
26 | console.log(`Error: Recipe ${recipe} does not exist.`); | ||
27 | return; | ||
28 | } | ||
29 | |||
30 | console.log('Emptying directory...'); | ||
31 | |||
32 | await fs.emptyDir(recipeSrc); | ||
33 | |||
34 | console.log('Copying data...'); | ||
35 | |||
36 | await fs.copy(recipePkg, recipeSrc); | ||
37 | |||
38 | console.log('Done'); | ||
39 | })(); \ No newline at end of file | ||