From 51ef0d0680e53d61836bf85e14acea322df312fa Mon Sep 17 00:00:00 2001 From: Leonardo Bressan Motyczka Date: Tue, 22 Oct 2019 03:00:18 +0000 Subject: [PATCH] Update test-unit to allow double dash args --- bin/test.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/test.js b/bin/test.js index 775ec004..760908a3 100644 --- a/bin/test.js +++ b/bin/test.js @@ -15,15 +15,22 @@ let testFiles = [ './out/**/*test.js' ]; -// ability to inject particular test files via -// yarn test [testFileA testFileB ...] +let flagArgs = []; + if (process.argv.length > 2) { - testFiles = process.argv.slice(2); + const args = process.argv.slice(2); + flagArgs = args.filter(e => e.startsWith('--')); + // ability to inject particular test files via + // yarn test [testFileA testFileB ...] + files = args.filter(e => !e.startsWith('--')); + if(files.length){ + testFiles = files; + } } const run = cp.spawnSync( path.resolve(__dirname, '../node_modules/.bin/mocha'), - testFiles, + [...testFiles, ...flagArgs], { cwd: path.resolve(__dirname, '..'), env, @@ -31,4 +38,4 @@ const run = cp.spawnSync( } ); -process.exit(run.status); \ No newline at end of file +process.exit(run.status);