Skip to content

Commit

Permalink
refactor: migrate to maven dir layout, update zx to v6.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 2, 2022
1 parent 607b5cd commit 71ef024
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 57 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
# 🦪 zx-extra
[zx](https://github.com/google/zx) with some useful extras
[zx](https://github.com/google/zx) with some out-of-scope extras.

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

# yarn
npm i zx-extra
yarn add zx-extra
```

## Usage
### ``$.raw`command` ``
Evaluates target cmd as is with disabled `shq`.

### `$.raw`
Evaluates target cmd as is without `shq`.
```js
const cmd = 'echo foo'
const msg = 'bar'
const output = (await $.raw`${cmd} ${msg}`).toString().trim()
// $ echo foo bar
```

### ``$.silent`command` `` (merged as `quiet`)
Sets `verbose = false` for once invocation.
### `$.silent`
_merged as [bf88f50](bf88f5064b31dea79da4999f25425ca0fe0b8013)_
Sets `verbose = false` for a single invocation.
```js
await $.silent`echo foo`
// <no output in console>
```

### ~~`` $.fs / global.fs ``~~ (merged)
### ~~` $.fs / global.fs `~~
_merged as [d8b6b87](73cd163d710f88d1ff835ffc3e76214eca07bb9b)_
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 ``~~ (merged)
### ~~`` global.argv ``~~
_merged as [d8b6b87](https://github.com/google/zx/commit/d8b6b87e5d48023fc23fd2a4f8513a896ee13c68)_
Represents parsed with [minimist](https://www.npmjs.com/package/minimist) script arguments
```js
// zx-extra test.mjs --foo=bar
Expand Down
82 changes: 48 additions & 34 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
"name": "zx-extra",
"version": "0.0.4",
"description": "zx with some useful extras",
"main": "index.mjs",
"main": "./src/main/js/index.mjs",
"type": "module",
"bin": {
"zx-extra": "./cli.mjs"
"zx-extra": "./src/main/js/cli.mjs"
},
"scripts": {
"test": "node cli.mjs test.mjs",
"test": "node src/main/js/cli.mjs src/test/js/test.mjs",
"publish": "npm publish --no-git-tag-version",
"publish:beta": "npm publish --no-git-tag-version --tag beta",
"publish:rc": "npm publish --no-git-tag-version --tag rc"
},
"files": [
"*.mjs",
"src/js",
"README.md",
"LICENSE"
],
Expand All @@ -34,7 +35,7 @@
},
"homepage": "https://github.com/qiwi/zx-extra#readme",
"dependencies": {
"@types/node": "^17.0.26",
"zx": "^6.1.0"
"@types/node": "^17.0.38",
"zx": "^6.2.0"
}
}
2 changes: 1 addition & 1 deletion cli.mjs → src/main/js/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node

import './index.mjs'
import 'zx/zx.mjs'
import 'zx/cli'
File renamed without changes.
6 changes: 2 additions & 4 deletions index.mjs → src/main/js/index.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {$} from 'zx'
import {$, quiet} from 'zx'

export * from 'zx'

Expand All @@ -13,8 +13,6 @@ $.raw = async (...args) => {
}

$.silent = async (...args) => {
const v = $.verbose
$.verbose = false
// https://github.com/google/zx/pull/134
return $(...args).finally(() => {$.verbose = v})
return quiet($(...args))
}
8 changes: 4 additions & 4 deletions test.mjs → src/test/js/test.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {$} from './index.mjs'
import {$} from '../../main/js/index.mjs'

import {strict as assert} from 'node:assert'

// $.raw
{
const cmd = 'echo foo'
const cmd = 'echo raw foo'
const msg = 'bar'
const output = (await $.raw`${cmd} ${msg}`).toString().trim()
assert(output === 'foo bar')
assert(output === 'raw foo bar')
}

// $.silent
{
await $.silent`echo foo`
await $.silent`echo silent`
}

// fs-extra
Expand Down

0 comments on commit 71ef024

Please sign in to comment.