Commit b1ca232
Changed files (5)
src/globals.ts
@@ -31,6 +31,7 @@ declare global {
var fs: typeof _.fs
var glob: typeof _.glob
var globby: typeof _.globby
+ var minimist: typeof _.minimist
var nothrow: typeof _.nothrow
var os: typeof _.os
var path: typeof _.path
src/goods.ts
@@ -24,6 +24,7 @@ import chalk from 'chalk'
export { default as chalk } from 'chalk'
export { default as fs } from 'fs-extra'
export { default as which } from 'which'
+export { default as minimist } from 'minimist'
export { default as YAML } from 'yaml'
export { default as path } from 'node:path'
export { default as os } from 'node:os'
test/goods.test.js
@@ -79,6 +79,25 @@ test('which() available', async () => {
assert.is(which.sync('npm'), await which('npm'))
})
+test('minimist available', async () => {
+ assert.is(typeof minimist, 'function')
+})
+
+test('minimist works', async () => {
+ assert.equal(
+ minimist(
+ ['--foo', 'bar', '-a', '5', '-a', '42', '--force', './some.file'],
+ { boolean: 'force' }
+ ),
+ {
+ a: [5, 42],
+ foo: 'bar',
+ force: true,
+ _: ['./some.file'],
+ }
+ )
+})
+
test('sleep() works', async () => {
const now = Date.now()
await sleep(100)
package-lock.json
@@ -1,12 +1,12 @@
{
"name": "zx",
- "version": "7.2.2",
+ "version": "7.2.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "zx",
- "version": "7.2.2",
+ "version": "7.2.3",
"license": "Apache-2.0",
"dependencies": {
"@types/fs-extra": "^11.0.1",
README.md
@@ -333,8 +333,13 @@ console.log(YAML.parse('foo: bar').foo)
### `minimist` package
-The [minimist](https://www.npmjs.com/package/minimist) package available
-as global const `argv`.
+The [minimist](https://www.npmjs.com/package/minimist) package.
+
+```js
+let myCustomArgv = minimist(process.argv.slice(2), { boolean: ["force", "help"] })
+```
+
+A minimist-parsed version of the process args as `argv` (parsed without any config).
```js
if (argv.someFlag) {