Skip to content

Commit

Permalink
cleaned up the code by moving the prefixed arguments removal to getcl…
Browse files Browse the repository at this point in the history
…iargs
  • Loading branch information
draganescu committed Mar 15, 2019
1 parent 3bb652a commit a50944e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/scripts/scripts/test-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const jest = require( 'jest' );
const {
fromConfigRoot,
getCliArg,
getCliArgs,
hasCliArg,
hasProjectFile,
hasJestConfig,
cleanUpArgs,
} = require( '../utils' );

// Provides a default config path for Puppeteer when jest-puppeteer.config.js
Expand All @@ -46,8 +46,8 @@ const runInBand = ! hasRunInBand ?
const cleanUpPrefixes = [ '--puppeteer-' ];

if ( hasCliArg( '--puppeteer-interactive' ) ) {
process.env.PUPPETEER_HEADLESS = false;
process.env.PUPPETEER_HEADLESS = 'false';
process.env.PUPPETEER_SLOWMO = getCliArg( '--puppeteer-slowmo' ) || 80;
}

jest.run( [ ...config, ...runInBand, ...cleanUpArgs( cleanUpPrefixes ) ] );
jest.run( [ ...config, ...runInBand, ...getCliArgs( cleanUpPrefixes ) ] );
7 changes: 0 additions & 7 deletions packages/scripts/utils/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ const getCliArg = ( arg ) => {
}
};

const cleanUpArgs = ( prefixes ) => {
return getCliArgs().filter( ( arg ) => {
return ! prefixes.some( ( prefix ) => arg.startsWith( prefix ) );
} );
};

const hasCliArg = ( arg ) => getCliArg( arg ) !== undefined;

const handleSignal = ( signal ) => {
Expand Down Expand Up @@ -88,5 +82,4 @@ module.exports = {
getCliArgs,
hasCliArg,
spawnScript,
cleanUpArgs,
};
10 changes: 9 additions & 1 deletion packages/scripts/utils/process.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
const getCliArgs = () => process.argv.slice( 2 );
const getCliArgs = ( excludePrefixes ) => {
const args = process.argv.slice( 2 );
if ( excludePrefixes ) {
return args.filter( ( arg ) => {
return ! excludePrefixes.some( ( prefix ) => arg.startsWith( prefix ) );
} );
}
return args;
};

module.exports = {
exit: process.exit,
Expand Down

0 comments on commit a50944e

Please sign in to comment.