Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pnpm #3

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"url": "https://github.com/go-task/go-npm.git"
},
"homepage": "https://github.com/go-task/go-npm",
"dependencies": {
"used-pm": "^1.0.0"
},
"devDependencies": {
"esbuild": "^0.12.17",
"jest": "^24.5.0",
Expand Down
7 changes: 7 additions & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { join } = require('path');
const { exec } = require('child_process');
const { existsSync, readFileSync } = require('fs');
const mkdirp = require('mkdirp');
const usedPM =require('used-pm');

// Mapping from Node's `process.arch` to Golang's `$GOARCH`
const ARCH_MAPPING = {
Expand Down Expand Up @@ -33,10 +34,16 @@ function getInstallationPath(callback) {
// Ex: /Users/foo/.nvm/versions/node/v4.3.0
const env = process.env;

// Get the package manager who is running the script
// This is needed since PNPM works in a different way than NPM or YARN.
const packageManager = usedPM();

if (env && env.npm_config_prefix) {
dir = join(env.npm_config_prefix, 'bin');
} else if (env && env.npm_config_local_prefix) {
dir = join(env.npm_config_local_prefix, join('node_modules', '.bin'));
} else if (packageManager.name.toLowerCase() === 'pnpm') {
dir = join(process.cwd(), 'node_modules', '.bin');
} else {
return callback(new Error('Error finding binary installation directory'));
}
Expand Down