When links are not preserved, set NODE_PATH for binstubs #528

Merged
merged 3 commits into from Jan 9, 2017

Projects

None yet

2 participants

@zkochan
Collaborator
zkochan commented Jan 8, 2017 edited

This solves lots of issues that pnpm currently has on Node.js 4. Hopefully it also allows the usage of pnpm without the --preserve-symlinks option.

Ref #527

Most of the magic was done in cmd-shim here

@zkochan zkochan added the ready for CR label Jan 8, 2017
zkochan added some commits Jan 8, 2017
@zkochan zkochan fix(bin): set NODE_PATH
When links are not preserved, set NODE_PATH for binstubs

Ref #527
19b5769
@zkochan zkochan feat: support preserve-symlinks config
preserve-symlinks is true by default on Node versions that
support it
7628bed
@zkochan zkochan chore(package): ⬆️ @zkochan/cmd-shim@2.2.0
8cad286
@zkochan
Collaborator
zkochan commented Jan 9, 2017 edited

This will probably not solve the issue for when the global installation of tools is executed.

For instance, if the global installation of standard is executed, it searches for the local installation and starts it on its own via a require.resolve, not via the binstub.

Code like this is frequently used in such tools:

#!/usr/bin/env node
'use strict'
var loudRejection = require('loud-rejection')
loudRejection()

var resolve = require('resolve')
var cwd = process.cwd()

var localCLI
try {
  localCLI = resolve.sync('mos/bin/mos', { basedir: cwd })
} catch (err) {
  localCLI = __filename
}

if (localCLI && localCLI !== __filename) {
  console.log('Using local install of mos')
  require(localCLI)
} else {
  require('../dist/cli')
}
@iamstarkov

🙏

@zkochan zkochan merged commit af4d86b into master Jan 9, 2017

4 checks passed

continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@zkochan zkochan deleted the issue527 branch Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment