spawn-wrap icon indicating copy to clipboard operation
spawn-wrap copied to clipboard

errors when .sh script run with shim

Open bcoe opened this issue 8 years ago • 2 comments

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:

    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:

    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?

bcoe avatar Feb 28 '16 20:02 bcoe