Skip to content

Commit

Permalink
refactor: migrate to zx v6
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Apr 28, 2022
1 parent 4e2ceac commit 607b5cd
Show file tree
Hide file tree
Showing 6 changed files with 751 additions and 238 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# zx-extra
# 🦪 zx-extra
[zx](https://github.com/google/zx) with some useful extras

## Install
```shell
# npm
npm i zx-extra

# yarn
npm i zx-extra
```

Expand All @@ -16,20 +20,20 @@ const output = (await $.raw`${cmd} ${msg}`).toString().trim()
// $ echo foo bar
```

### ``$.silent`command` ``
### ``$.silent`command` `` (merged as `quiet`)
Sets `verbose = false` for once invocation.
```js
await $.silent`echo foo`
// <no output in console>
```

### `` $.fs / global.fs ``
### ~~`` $.fs / global.fs ``~~ (merged)
Refers to [fs-extra](https://www.npmjs.com/package/fs-extra) instead of standard Node.js `fs` module.
```js
await fs.copy('/tmp/myfile', '/tmp/mynewfile')
```

### `` global.argv ``
### ~~`` global.argv ``~~ (merged)
Represents parsed with [minimist](https://www.npmjs.com/package/minimist) script arguments
```js
// zx-extra test.mjs --foo=bar
Expand Down
9 changes: 0 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import type fs from 'fs-extra'
import type minimist from 'minimist'
export * from 'zx'

interface $ {
fs: fs
raw: $
silent: $
}

declare global {
var argv: ReturnType<minimist>
// https://github.com/google/zx/pull/145
// var fs: fs
}
10 changes: 1 addition & 9 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import {$} from 'zx'
import fs from 'fs-extra'
import minimist from 'minimist'

const argv = minimist(process.argv.slice(2))
export * from 'zx'

$.fs = {...$.fs, ...fs}
$.raw = async (...args) => {
const q = $.quote
$.quote = v => v
Expand All @@ -21,8 +18,3 @@ $.silent = async (...args) => {
// https://github.com/google/zx/pull/134
return $(...args).finally(() => {$.verbose = v})
}

Object.assign(global, {
fs: $.fs,
argv
})
Loading

0 comments on commit 607b5cd

Please sign in to comment.