Add flexibility to run any command (with current file path placeholders) #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to have more flexibility and control over the command that is run, I have made the following changes:
npm
command as firstspawn()
arg, I have made it so that any command can be used. This allows one to use any custom command - like docker commands or anything else that does not begin withnpm
. The default command is stillnpm test
. Along with this comes the security implication that any malicious command could do serious damage.Due to the nature of
spawn()
, I have replaced the current "testScript" config textfield with an array of strings named "testCommandArray". Array item 0 is used as the firstspawn()
arg, and the rest are passed intospawn()
arg 2.Here is an example with placeholders. The following configuration is an array of 4 strings:
Which has this JSON representation:
The command that is run looks like:
npm run testDebug test/something.test.js
. If your test runner requires other command line args like a--
before the file path arg, you have the flexibility to add that. I tried using docker & docker-compose exec/run commands using this approach and it works as long as you do not allocate a TTY (see-t
and-T
flags).Just a note about the changes:
.vscode/tasks.json
- these were made automatically by VSCode.package.json
- I updated the deps to latest versions. These changes are probably not required, and may affect older Node version (8?) compatibility. I updated@types/node
to 12.Addresses #27 and #24.