Skip to content

Commit

Permalink
Merge pull request #154 from bcomnes/voxpelli/issue153
Browse files Browse the repository at this point in the history
Switch to JS-based `which` command
  • Loading branch information
bcomnes authored Oct 18, 2024
2 parents 97d19db + fb2416b commit ec1c598
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/run-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

const fs = require('fs')
const path = require('path')

const ansiStylesPromise = import('ansi-styles')
const parseArgs = require('shell-quote').parse
const which = require('which')

const createHeader = require('./create-header')
const createPrefixTransform = require('./create-prefix-transform-stream')
const spawn = require('./spawn')
const ansiStylesPromise = import('ansi-styles')

// ------------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -185,7 +188,7 @@ module.exports = function runTask (task, options) {
// Attempt to figure out whether we're running via pnpm
const projectRoot = path.dirname(options.packageInfo.path)
const hasPnpmLockfile = fs.existsSync(path.join(projectRoot, 'pnpm-lock.yaml'))
const { status: pnpmFound, output: pnpmWhichOutput } = await spawn('which', 'pnpm', { silent: true })
const { status: pnpmFound, output: pnpmWhichOutput } = await which('pnpm', { nothrow: true })
if (hasPnpmLockfile && __dirname.split(path.delimiter).includes('.pnpm') && pnpmFound) {
execPath = pnpmWhichOutput
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"minimatch": "^9.0.0",
"pidtree": "^0.6.0",
"read-package-json-fast": "^3.0.2",
"shell-quote": "^1.7.3"
"shell-quote": "^1.7.3",
"which": "^3.0.1"
},
"devDependencies": {
"auto-changelog": "^2.2.0",
Expand Down

0 comments on commit ec1c598

Please sign in to comment.