diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-01-25 23:06:18 +0100 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-01-25 23:06:18 +0100 |
| commit | f9fbf70170421fc5e02b95923ff137e0234cad69 (patch) | |
| tree | 6e4e0e5e2aca7f391e5aa9c5dbd4f3d8498c674f /gulpfile.js | |
| parent | 875a9c9e55b929eb29aac31b46b3f6b0108737d1 (diff) | |
Improve gulp config option handling
Diffstat (limited to 'gulpfile.js')
| -rw-r--r-- | gulpfile.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gulpfile.js b/gulpfile.js index fb7605cc..941b1119 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,16 +34,23 @@ const bower = require('gulp-bower'); * @returns {Object} the config file contents. */ function getConfigFile() { - const configFilePath = argv.config; + const configInput = argv.config; - if (configFilePath === undefined) { - gulpUtil.log(gulpUtil.colors.red('Config file argument missing\n'), "Usage:\n" + - " $ gulp --config=config.json"); + if (configInput === undefined) { + gulpUtil.log(gulpUtil.colors.red('Config file argument missing\n'), 'Usage:\n' + + ' $ gulp --config=config.json'); throw new Exception(); } try { - return require('./' + configFilePath); + let configFilePath; + if (configInput.indexOf('/') === -1) { + configFilePath = './' + configInput; + } else { + configFilePath = configInput; + } + + return require(configFilePath); } catch (error) { gulpUtil.log(gulpUtil.colors.red('Config file could not be read'), error); throw new Exception(); @@ -83,7 +90,7 @@ const scriptsFilePaths = scriptsFileNames.map(function (fileName) { }); gulp.task('scripts', function () { - var tasks = scriptsFilePaths.map(function (entry, index) { + const tasks = scriptsFilePaths.map(function (entry, index) { return browserify({entries: [entry]}) .plugin(tsify, {insertGlobals: true}) .bundle() |
