From 1e6e6aff48be8fa2470c383d1c459c3bf852b835 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sun, 2 Feb 2020 17:35:22 +0100 Subject: Add load recipe script --- scripts/load.js | 39 +++++++++++++++++++++++++++++++++++++++ scripts/package.json | 3 ++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 scripts/load.js (limited to 'scripts') 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 @@ +/** + * Load recipe into development folder + */ +const fs = require('fs-extra'); +const path = require('path'); + +console.log('load: Load recipe into development folder'); +console.log('This command will empty the recipe_src folder. Please make sure that there are no important files in that directory.'); + +const recipe = process.argv[2]; +if (!recipe) { + console.log('Usage: yarn load [recipe]'); + return; +} + +console.log(`Loading ${recipe}`); + +// Create paths to important files +const recipeSrc = path.join(__dirname, 'recipe_src'); +const recipePkg = path.join(__dirname, '../', 'uncompressed', recipe); + +// Let us work in an async environment +(async () => { + // Check that recipe folder exists + if (!await fs.pathExists(recipePkg)) { + console.log(`Error: Recipe ${recipe} does not exist.`); + return; + } + + console.log('Emptying directory...'); + + await fs.emptyDir(recipeSrc); + + console.log('Copying data...'); + + await fs.copy(recipePkg, recipeSrc); + + console.log('Done'); +})(); \ No newline at end of file diff --git a/scripts/package.json b/scripts/package.json index 63aeefa..56c62ed 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -18,6 +18,7 @@ "package": "node package.js", "verify": "node verify.js", "update": "node update.js", - "github": "node add_github.js" + "github": "node add_github.js", + "load": "node load.js" } } -- cgit v1.2.3-54-g00ecf