Skip to content

Commit

Permalink
feat: integrate node-ip package
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 3, 2022
1 parent 638f0ba commit d7e74ed
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ yarn add zx-extra
```

## Usage
Inherits zx, so all origin methods are available.
Inherits zx, so all origin methods are available. Follow [the upstream docs](https://github.com/google/zx) for details.

## Extras

### `ip`
Resolves the current IP address via [node-ip](https://github.com/indutny/node-ip).
```js
import {ip} from 'zx-extra'

ip.address() // 1.2.3.4
```

### `semver`
Semantic versioning api from [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'

Expand Down
11 changes: 11 additions & 0 deletions npm-shrinkwrap.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@qiwi/deep-proxy": "^1.9.0",
"@types/node": "^17.0.38",
"@types/semver": "^7.3.9",
"ip": "^1.1.8",
"npm-run-path": "^5.1.0",
"zx": "^6.2.0"
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/js/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {isTemplateSignature, randomId} from './util.mjs'
import {npmRunPath} from 'npm-run-path'
import {DeepProxy} from '@qiwi/deep-proxy'

export { semver } from './semver.mjs'
export * from 'zx'
export { default as ip } from 'ip'
export { semver } from './semver.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} from '../../main/js/index.mjs'
import {$, semver, createHook, ip} from '../../main/js/index.mjs'

// $.raw
{
Expand Down Expand Up @@ -105,3 +105,8 @@ import {$, semver, createHook} from '../../main/js/index.mjs'
$.verbose = 2
}

// ip
{
assert(/(\d+\.){3}\d+/.test(ip.address()))
}

0 comments on commit d7e74ed

Please sign in to comment.