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 9 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

@addaleax any thoughts about this old issue that's open on nyc?

bcoe avatar Apr 11 '16 00:04 bcoe

@bcoe I’d love to help, but the branches mentioned the issue are gone, and it appears quite a bit has happened in the semantic-release since the original report… do you have some kind of working reproduction without it? Or maybe the git SHAs from back then?

addaleax avatar Apr 11 '16 01:04 addaleax