-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: more lightweight npm bin discovery in windows
- Loading branch information
Showing
7 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
// This is a single-use bin to help windows discover the proper prefix for npm without having to load all of npm first | ||
// It does not accept argv params | ||
|
||
const path = require('path') | ||
const Config = require('@npmcli/config') | ||
const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions') | ||
const config = new Config({ | ||
npmPath: path.dirname(__dirname), | ||
// argv is explicitly not looked at since prefix is not something that can be changed via argv | ||
argv: [], | ||
definitions, | ||
flatten, | ||
shorthands, | ||
excludeNpmCwd: false, | ||
}) | ||
|
||
config.load().then(() => { | ||
console.log(config.globalPrefix) | ||
}).catch(err => { | ||
console.trace(err) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters