Skip to content

Commit

Permalink
feat!: move to zx v7
Browse files Browse the repository at this point in the history
BREAKING CHANGE: see google/zx@6.2.5...7.0.0
  • Loading branch information
antongolub committed Jul 2, 2022
1 parent 80027af commit 58c671d
Show file tree
Hide file tree
Showing 3 changed files with 666 additions and 656 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
},
"homepage": "https://github.com/qiwi/zx-extra#readme",
"dependencies": {
"@qiwi/deep-proxy": "^2.0.1",
"@qiwi/deep-proxy": "^2.0.2",
"@types/ip": "^1.1.0",
"@types/node": "^17.0.42",
"@types/semver": "^7.3.9",
"@types/node": "^18.0.0",
"@types/semver": "^7.3.10",
"ip": "^1.1.8",
"is-reachable": "^5.2.0",
"is-reachable": "^5.2.1",
"npm-run-path": "^5.1.0",
"tempy": "^3.0.0",
"zx": "^6.2.5"
"zx": "^7.0.6"
}
}
16 changes: 11 additions & 5 deletions src/main/js/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {$ as _$, quiet, ProcessPromise} from 'zx'
import {ctx as _ctx} from 'zx/experimental'
import {$ as _$, quiet, ProcessPromise, within} from 'zx'
import {isTemplateSignature, randomId} from './util.mjs'
import {npmRunPath} from 'npm-run-path'
import {DeepProxy} from '@qiwi/deep-proxy'
Expand All @@ -24,7 +23,7 @@ export const $ = new DeepProxy(_$, ({DEFAULT, target: t, trapName, args}) => {
return DEFAULT
})

export const ctx = (cb, ref = $.bind(null)) => _ctx(cb, ref)
export const ctx = (cb, ref = $) => within(() => cb(ref))

$.raw = async (...args) => $.o({quote: v => v})(...args)

Expand All @@ -34,11 +33,18 @@ $.silent = async (...args) => quiet($(...args))
$.o = $.opt =
(opts) =>
(...args) =>
ctx(($) => Object.assign($, opts)(...args))
ctx(($) => {
Object.assign(_$, opts)
const p = $(...args)
if (p._snapshot) p._nothrow = true
return p
})

export const createHook = (opts, name = randomId(), cb = (v) => v, configurable) => {
ProcessPromise.prototype[name] = function (...args) {
Object.assign(this.ctx, opts)
Object.assign(this._snapshot, opts)
if (this._snapshot) this._nothrow = true

return cb(this, ...args)
}

Expand Down
Loading

0 comments on commit 58c671d

Please sign in to comment.