Skip to content

Commit

Permalink
feat: integrate tempy package
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 3, 2022
1 parent 14dbb0c commit b260658
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 5 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ ip.address() // 1.2.3.4
```

### `semver`
Semantic versioning API provided by [node-semver](https://github.com/npm/node-semver)
Semantic versioning API provided by [node-semver](https://github.com/npm/node-semver).
```js
import {semver} from 'zx-extra'

semver.gte('1.0.1', '1.0.0')
```

### `tempy`
Creates [temp dirs and files](https://github.com/sindresorhus/tempy).
```js
import {tempy} from 'zx-extra'

temporaryFile() // '/private/var/folders/p0/p7xckky93s30rshd51gs4pdc0000gn/T/1b7e9277860eb90b94aad816d4f66f8e'
temporaryDirectory() // '/private/var/folders/p0/p7xckky93s30rshd51gs4pdc0000gn/T/1b7e9277860eb90b94aad816d4f66f8e'
```

### $.preferLocal
In npm run scripts you can execute locally installed binaries by name. This enables the same for zx.
```js
Expand Down
153 changes: 153 additions & 0 deletions npm-shrinkwrap.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
"homepage": "https://github.com/qiwi/zx-extra#readme",
"dependencies": {
"@qiwi/deep-proxy": "^1.9.0",
"@types/ip": "^1.1.0",
"@types/node": "^17.0.38",
"@types/semver": "^7.3.9",
"ip": "^1.1.8",
"npm-run-path": "^5.1.0",
"tempy": "^3.0.0",
"zx": "^6.2.0"
}
}
3 changes: 3 additions & 0 deletions src/main/js/goods.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * as tempy from 'tempy'
export { default as ip } from 'ip'
export { semver } from './semver.mjs'
8 changes: 7 additions & 1 deletion src/main/js/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import * as semver from 'semver'
import {ProcessPromise} from 'zx'
import * as ip from 'ip'
import * as tempy from 'tempy'

export * from 'zx'
export { semver }
export {
ip,
semver,
tempy
}

interface $ {
raw: $
Expand Down
3 changes: 1 addition & 2 deletions src/main/js/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {npmRunPath} from 'npm-run-path'
import {DeepProxy} from '@qiwi/deep-proxy'

export * from 'zx'
export { default as ip } from 'ip'
export { semver } from './semver.mjs'
export * from './goods.mjs'

export const $ = new DeepProxy(_$, ({DEFAULT, trapName, args}) => {
if (trapName === 'apply') {
Expand Down
7 changes: 6 additions & 1 deletion src/test/js/test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {strict as assert} from 'node:assert'
import {$, semver, createHook, ip} from '../../main/js/index.mjs'
import {$, semver, createHook, ip, tempy} from '../../main/js/index.mjs'

// $.raw
{
Expand Down Expand Up @@ -110,3 +110,8 @@ import {$, semver, createHook, ip} from '../../main/js/index.mjs'
assert(/(\d+\.){3}\d+/.test(ip.address()))
}

// tempy
{
assert(typeof tempy.temporaryDirectory() === 'string')
assert(typeof tempy.rootTemporaryDirectory === 'string')
}

0 comments on commit b260658

Please sign in to comment.