Commit f65b3af
Changed files (7)
.github/PULL_REQUEST_TEMPLATE.md
@@ -3,4 +3,5 @@ Fixes #<issue_number_goes_here>
> It's a good idea to open an issue first for discussion.
- [ ] Tests pass
-- [ ] Appropriate changes to README are included in PR
\ No newline at end of file
+- [ ] Appropriate changes to README are included in PR
+- [ ] Types updated
src/globals.d.ts
@@ -11,6 +11,7 @@ import {
path as _path,
question,
sleep,
+ which as _which,
} from './index'
declare global {
@@ -28,4 +29,5 @@ declare global {
var path: typeof _path
var question: question
var sleep: sleep
+ var which: typeof _which
}
src/index.d.ts
@@ -22,6 +22,7 @@ import {ChalkInstance} from 'chalk'
import * as _yaml from 'yaml'
import _fetch from 'node-fetch'
import {ParsedArgs} from 'minimist'
+import * as _which from 'which'
interface $ {
(pieces: TemplateStringsArray, ...args: any[]): ProcessPromise<ProcessOutput>
@@ -78,3 +79,4 @@ export const path: typeof _path
export const question: question
export const sleep: sleep
export const quiet: quiet
+export const which: typeof _which
src/index.mjs
@@ -26,7 +26,7 @@ import YAML from 'yaml'
import minimist from 'minimist'
import psTreeModule from 'ps-tree'
-export {chalk, fs, os, path, YAML}
+export {chalk, fs, os, path, YAML, which}
export const sleep = promisify(setTimeout)
export const argv = minimist(process.argv.slice(2))
export const globby = Object.assign(function globby(...args) {
@@ -52,6 +52,7 @@ export function registerGlobals() {
question,
sleep,
YAML,
+ which,
})
}
package.json
@@ -32,6 +32,7 @@
"@types/fs-extra": "^9.0.13",
"@types/minimist": "^1.2.2",
"@types/node": "^17.0",
+ "@types/which": "^2.0.1",
"chalk": "^5.0.1",
"fs-extra": "^10.0.1",
"globby": "^13.1.1",
README.md
@@ -300,6 +300,16 @@ The [minimist](https://www.npmjs.com/package/minimist) package.
Available as global const `argv`.
+#### `which`
+
+The [which](https://github.com/npm/node-which) package.
+
+```js
+let node = await which('node')
+
+let node = which.sync('node')
+```
+
### Configuration
#### `$.shell`
test.mjs
@@ -257,6 +257,10 @@ if (test('Retry works')) {
assert(Date.now() >= now + 50 * (5 - 1))
}
+if (test('which available')) {
+ assert.equal(which.sync('npm'), await which('npm'))
+}
+
let version
if (test('require() is working in ESM')) {
let data = require('./package.json')