port-detective 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/cli.js +30 -0
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ TypeScript APIs. Published releases install a matching platform CLI package auto
|
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
|
-
Install the package from npm
|
|
8
|
+
Install the published package from npm:
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
11
|
npm install port-detective
|
|
@@ -16,6 +16,17 @@ checkouts omit generated platform packages; build the CLI locally or set
|
|
|
16
16
|
`PORT_DETECTIVE_BIN` when developing from this directory. `binaryPath` always overrides
|
|
17
17
|
automatic resolution, and unsupported platforms can use a CLI on `PATH`.
|
|
18
18
|
|
|
19
|
+
The published package also exposes the CLI command through npm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx --no-install port-detective check 3000
|
|
23
|
+
npx --no-install port-detective scan --ports 3000,8080
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
After installation, `port-detective` is available from npm scripts and
|
|
27
|
+
`node_modules/.bin`. The wrapper uses the matching bundled platform binary and falls
|
|
28
|
+
back to `PORT_DETECTIVE_BIN` or a CLI on `PATH`.
|
|
29
|
+
|
|
19
30
|
## Use
|
|
20
31
|
|
|
21
32
|
```js
|
package/cli.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
const { binaryRelativePath, platformPackageName } = require("./platform");
|
|
7
|
+
|
|
8
|
+
function resolveCli() {
|
|
9
|
+
if (process.env.PORT_DETECTIVE_BIN) return process.env.PORT_DETECTIVE_BIN;
|
|
10
|
+
const packageName = platformPackageName();
|
|
11
|
+
if (packageName) {
|
|
12
|
+
try {
|
|
13
|
+
return require.resolve(`${packageName}/${binaryRelativePath()}`);
|
|
14
|
+
} catch {
|
|
15
|
+
// Fall back to a separately installed CLI or PATH.
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return process.platform === "win32" ? "port-detective.exe" : "port-detective";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = spawnSync(resolveCli(), process.argv.slice(2), {
|
|
22
|
+
stdio: "inherit",
|
|
23
|
+
windowsHide: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (result.error) {
|
|
27
|
+
console.error(`failed to execute port-detective: ${result.error.message}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "port-detective",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Minimal-dependency Node.js client for the port-detective CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"port-detective": "cli.js"
|
|
9
|
+
},
|
|
7
10
|
"types": "index.d.ts",
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
@@ -14,6 +17,7 @@
|
|
|
14
17
|
},
|
|
15
18
|
"files": [
|
|
16
19
|
"index.js",
|
|
20
|
+
"cli.js",
|
|
17
21
|
"platform.js",
|
|
18
22
|
"index.d.ts",
|
|
19
23
|
"README.md",
|
|
@@ -43,11 +47,11 @@
|
|
|
43
47
|
"access": "public"
|
|
44
48
|
},
|
|
45
49
|
"optionalDependencies": {
|
|
46
|
-
"port-detective-cli-win32-x64": "1.1.
|
|
47
|
-
"port-detective-cli-win32-arm64": "1.1.
|
|
48
|
-
"port-detective-cli-darwin-x64": "1.1.
|
|
49
|
-
"port-detective-cli-darwin-arm64": "1.1.
|
|
50
|
-
"port-detective-cli-linux-x64": "1.1.
|
|
51
|
-
"port-detective-cli-linux-arm64": "1.1.
|
|
50
|
+
"port-detective-cli-win32-x64": "1.1.1",
|
|
51
|
+
"port-detective-cli-win32-arm64": "1.1.1",
|
|
52
|
+
"port-detective-cli-darwin-x64": "1.1.1",
|
|
53
|
+
"port-detective-cli-darwin-arm64": "1.1.1",
|
|
54
|
+
"port-detective-cli-linux-x64": "1.1.1",
|
|
55
|
+
"port-detective-cli-linux-arm64": "1.1.1"
|
|
52
56
|
}
|
|
53
57
|
}
|