Commit 2dc257b6 authored by Oliver Wirth's avatar Oliver Wirth
Browse files

Move presets folder location

parent 1ee41bbc
......@@ -13,7 +13,7 @@ Building the app for production mode can be done by running `npm run build`.
## Adding presets
The preset configuration files can be found in the folder src/presets.
The preset configuration files can be found in the folder `./presets/`.
On executing `npm start` or `npm run build` all presets are batched together into a single file called presets.json.
To add a new preset, simply place in the folder mentioned beforehand, preferably under the name presetXX.json (XX being any double digit number).
\ No newline at end of file
......@@ -8,26 +8,26 @@
const fs = require('fs');
const path = require('path');
const preset_fname = 'presets.json'
const preset_path = path.join(__dirname, 'src', 'presets');
const targetName = 'presets.json';
const sourcePath = path.join(__dirname, 'presets');
const targetPath = path.join(__dirname, 'src', 'presets', targetName);
fs.readdir(preset_path, (err, files) => {
fs.readdir(sourcePath, (err, files) => {
if (err) {
throw err;
}
// Load single json files into a list
const presets = files
.filter(file => file.endsWith('.json') && file !== preset_fname)
.map(file => path.join(preset_path, file))
.filter(file => file.endsWith('.json'))
.map(file => path.join(sourcePath, file))
.map(require);
// Write list to file
fs.writeFile(path.join(preset_path, preset_fname), JSON.stringify(presets), err => {
fs.writeFile(targetPath, JSON.stringify(presets), err => {
if (err) {
throw err;
}
console.log('Successfully batched ' + presets.length + ' presets into ' + preset_fname);
console.log('Successfully batched ' + presets.length + ' presets into ' + targetName);
});
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment