boltpkg / bolt

⚡️ Super-powered JavaScript project management
MIT License
2.35k stars 82 forks source link

`bolt upgrade` should not wrap versioned packages with quotes #228

Closed DethAriel closed 5 years ago

DethAriel commented 5 years ago
Title Description
Version at least v0.22.4 through v0.23.2
Type Issue
node v10.6.0, v12.2.0
Operating System macOS Mojave 10.14.4
Short Description wrapping versioned packages with " causes yarn to fail parsing package name correctly under certain conditions
Detailed description too long, I suppose, see below the table

Now, this one is truly weird, but easily reproducible:

  1. Preconditions: you've got node, bolt, and yarn
  2. mkdir test && cd test
  3. yarn init -y
  4. yarn add lodash@^3

    (could actually be any package)

  5. node -e "require('child_process').execSync('bolt upgrade lodash@^4', { stdio: 'ignore' })"

    this will fail, which is the bug

  6. cat yarn-error.log | grep Error

    Error: https://registry.yarnpkg.com/%22lodash: Not found

Now, there's not a lot going on here, but here's what else I was able to find:

  1. { stdio: 'ignore' } plays a role, the same thing will happen with { stdio: 'pipe' }, but it actually succeeds with { stdio: 'inherit' } 🤯
  2. This lineseems to be the culprit - there's no need to quote-wrap arguments passed down to spawn
  3. On yarn's side, this function is the blowup point - when normalizePattern('"lodash@^4"') is invoked, it produces the following: { name: '"lodash', range: '^4"', hasVersion: true }

I'm very uncertain as to why stdio: 'inherit' succeeds, but it looks like quote-wrapping the args is redundant and can be safely removed.