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

Switch to JS-based which command #154

Merged
merged 1 commit into from
Oct 18, 2024
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
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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is lovely.

},
"devDependencies": {
"auto-changelog": "^2.2.0",
Expand Down
Loading