istanbuljs / istanbuljs/spawn-wrap

errors when .sh script run with shim

Open
#10 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
41
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I finally dug into the problem that @boennemann is seeing here:

https://github.com/bcoe/nyc/issues/34

tldr; this script fails when instrumented with spawn-wrap's shim:

https://github.com/semantic-release/semantic-release/blob/caribou/test/registry/start.sh

The logic that is causing the script to fail relates to paths being remapped to point to the spawn-wrap shim:

``` js
for (var i = 0; i < options.envPairs.length; i++) {
var ep = options.envPairs[i]
if (ep.match(pathRe)) {
pathEnv = ep.substr(5)
var k = ep.substr(0, 5)
options.envPairs[i] = k + workingDir + colon + pathEnv
}
}
```
## One Possible Solution

I managed to instrument `semantic-release`'s integration tests with `nyc`, by simply ignore the shell script that was causing issues:

``` js
var file = path.basename(options.file, '.exe')
if (~options.args.indexOf('./start.sh')) {
console.log(options.args)
return spawn.call(this, options)
}
```

I wonder if we should just have `spawn-wrap` accept a list of files to ignore? This might be a good way to help people get around edge-cases.
## A Better Solution

@isaacs any idea why remapping the `/^PATH=/` is causing trouble for this script in particular?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.