-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cli): add parseArgs test
- Loading branch information
Showing
3 changed files
with
52 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Parse cli args and split these to args for node js and the rest | ||
* | ||
* @param {string[]} rawArgs raw cli args | ||
* @returns {{cliArgs: string[], nodeArgs: string[]}} cli and nodejs args | ||
*/ | ||
module.exports = rawArgs => { | ||
const cliArgs = []; | ||
const nodeArgs = []; | ||
let isNodeArg = false; | ||
|
||
for (const value of rawArgs) { | ||
if (value === '--node-args') { | ||
isNodeArg = true; | ||
} else if (isNodeArg) { | ||
isNodeArg = false; | ||
nodeArgs.push(...value.split(' ')); | ||
} else { | ||
cliArgs.push(value); | ||
} | ||
} | ||
|
||
return { cliArgs, nodeArgs }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters