@oclif/plugin-version 2.2.56 → 2.2.57
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 +1 -1
- package/lib/commands/version.js +16 -7
- package/oclif.manifest.json +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ FLAG DESCRIPTIONS
|
|
|
27
27
|
Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
_See code: [src/commands/version.ts](https://github.com/oclif/plugin-version/blob/2.2.
|
|
30
|
+
_See code: [src/commands/version.ts](https://github.com/oclif/plugin-version/blob/2.2.57/src/commands/version.ts)_
|
|
31
31
|
<!-- commandsstop -->
|
|
32
32
|
|
|
33
33
|
# Contributing
|
package/lib/commands/version.js
CHANGED
|
@@ -2,21 +2,30 @@ import { Command, Flags } from '@oclif/core';
|
|
|
2
2
|
import { Ansis } from 'ansis';
|
|
3
3
|
import { execFile } from 'node:child_process';
|
|
4
4
|
import { EOL } from 'node:os';
|
|
5
|
+
import { dirname, resolve } from 'node:path';
|
|
6
|
+
import which from 'which';
|
|
5
7
|
const ansis = new Ansis();
|
|
6
8
|
async function getNpmDetails(pkg) {
|
|
7
|
-
return new Promise((
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
9
|
+
return new Promise((resolve_) => {
|
|
10
|
+
// Resolve npm from PATH only, excluding CWD. On Windows, both execFile (CreateProcess)
|
|
11
|
+
// and the `which` module resolve executables from CWD before PATH.
|
|
12
|
+
const cwd = resolve(process.cwd());
|
|
13
|
+
const npmPath = which.sync('npm', { nothrow: true });
|
|
14
|
+
if (!npmPath || dirname(resolve(npmPath)) === cwd) {
|
|
15
|
+
resolve_(false);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const useShell = /\.(cmd|bat)$/i.test(npmPath);
|
|
19
|
+
execFile(npmPath, ['view', pkg, '--json'], { shell: useShell }, (error, stdout) => {
|
|
11
20
|
if (error) {
|
|
12
|
-
|
|
21
|
+
resolve_(false);
|
|
13
22
|
}
|
|
14
23
|
else {
|
|
15
24
|
try {
|
|
16
|
-
|
|
25
|
+
resolve_(JSON.parse(stdout));
|
|
17
26
|
}
|
|
18
27
|
catch {
|
|
19
|
-
|
|
28
|
+
resolve_(false);
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
31
|
});
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/plugin-version",
|
|
3
3
|
"description": "A command that shows the CLI version",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.57",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/plugin-version/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@oclif/core": "^4",
|
|
9
|
-
"ansis": "^3.17.0"
|
|
9
|
+
"ansis": "^3.17.0",
|
|
10
|
+
"which": "^4"
|
|
10
11
|
},
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@commitlint/config-conventional": "^19",
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
"@types/chai": "^4.3.17",
|
|
18
19
|
"@types/mocha": "^10",
|
|
19
20
|
"@types/node": "^18",
|
|
21
|
+
"@types/which": "^3",
|
|
20
22
|
"chai": "^4.5.0",
|
|
21
23
|
"commitlint": "^19",
|
|
22
24
|
"eslint": "^9.39.5",
|