diff options
author | Lukas Eipert <git@leipert.io> | 2018-04-11 00:34:18 +0200 |
---|---|---|
committer | Lukas Eipert <git@leipert.io> | 2018-04-11 00:34:18 +0200 |
commit | bd1b2c665f612f304b68205bdf8fc96fdcfa3112 (patch) | |
tree | bee391414be8b838cc58b9e4375e89d45105f480 /config/karma.config.js | |
parent | 6b8f1a1e15a71ec28eb639a2f424e3f202e22dea (diff) | |
download | gitlab-ce-bd1b2c665f612f304b68205bdf8fc96fdcfa3112.tar.gz |
use commander for safer cli argument parsing
Diffstat (limited to 'config/karma.config.js')
-rw-r--r-- | config/karma.config.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/config/karma.config.js b/config/karma.config.js index 15f027c164c..61f02294157 100644 --- a/config/karma.config.js +++ b/config/karma.config.js @@ -1,5 +1,6 @@ var path = require('path'); var webpack = require('webpack'); +var argumentsParser = require('commander'); var webpackConfig = require('./webpack.config.js'); var ROOT_PATH = path.resolve(__dirname, '..'); @@ -14,14 +15,21 @@ if (webpackConfig.plugins) { }); } -var ignoreUpTo = process.argv.indexOf('config/karma.config.js') + 1; -var testFiles = process.argv.slice(ignoreUpTo).filter(arg => { - return !arg.startsWith('--'); -}); +var testFiles = argumentsParser + .option( + '-f, --filter-spec [filter]', + 'Filter run spec files by path. Multiple filters are like a logical OR.', + (val, memo) => { + memo.push(val); + return memo; + }, + [] + ) + .parse(process.argv).filterSpec; webpackConfig.plugins.push( new webpack.DefinePlugin({ - 'process.env.TEST_FILES': JSON.stringify(testFiles) , + 'process.env.TEST_FILES': JSON.stringify(testFiles), }) ); |