gulp-dynamic/tools/buildConfig.js
2021-02-17 12:23:08 +01:00

32 lines
871 B
JavaScript

const fs = require('fs'),
HelperUnit = require('./helperUnit'),
helper = new HelperUnit(),
config = {};
module.exports = {
config: config,
helper: helper,
prepare: function () {
if (!fs.existsSync(__dirname + '/../../buildConfig.json')) {
console.error("Cannot find Config JSON");
process.exit(40);
}
const baseDir = __dirname + '/../..';
const data = JSON.parse(fs.readFileSync(__dirname + '/../../buildConfig.json').toString());
const src = data['src'].replace(/(\$dir)/gm, baseDir);
const out = data['out'].replace(/(\$dir)/gm, baseDir);
helper.setConfig({
$dir: baseDir,
$out: out,
$src: src,
})
config.dir = baseDir;
config.src = src;
config.out = out;
config.js = data.js || [];
config.scss = data.scss || [];
this.js = config.js;
this.scss = config.scss;
}
}