@kevin0181/rcodex 0.0.2 → 0.0.3
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/package.json +1 -1
- package/scripts/postinstall.cjs +9 -17
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
1
|
const { execSync } = require("child_process");
|
|
4
2
|
const path = require("path");
|
|
5
3
|
|
|
6
|
-
function normalizePath(
|
|
4
|
+
function normalizePath(inputPath) {
|
|
7
5
|
try {
|
|
8
|
-
return path.resolve(
|
|
6
|
+
return path.resolve(inputPath.trim().replace(/[\\/]+/g, path.sep)).toLowerCase();
|
|
9
7
|
} catch {
|
|
10
|
-
return
|
|
8
|
+
return inputPath.toLowerCase();
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
try {
|
|
15
13
|
const prefix = execSync("npm config get prefix", { encoding: "utf8" }).trim();
|
|
16
|
-
|
|
17
|
-
if (process.platform === "win32") {
|
|
18
|
-
binDir = prefix;
|
|
19
|
-
} else {
|
|
20
|
-
binDir = path.join(prefix, "bin");
|
|
21
|
-
}
|
|
22
|
-
|
|
14
|
+
const binDir = process.platform === "win32" ? prefix : path.join(prefix, "bin");
|
|
23
15
|
const normalizedBinDir = normalizePath(binDir);
|
|
24
16
|
const paths = (process.env.PATH || "")
|
|
25
17
|
.split(path.delimiter)
|
|
26
|
-
.map(
|
|
18
|
+
.map((entry) => normalizePath(entry));
|
|
27
19
|
|
|
28
|
-
const isInPath = paths.some(
|
|
20
|
+
const isInPath = paths.some((entry) => entry === normalizedBinDir || entry === normalizedBinDir + path.sep);
|
|
29
21
|
|
|
30
22
|
if (!isInPath) {
|
|
31
23
|
console.warn("\n======================================================================");
|
|
32
|
-
console.warn("
|
|
24
|
+
console.warn("WARNING: The global npm binaries directory is not in your PATH.");
|
|
33
25
|
console.warn("Please add the following directory to your PATH environment variable:");
|
|
34
26
|
console.warn(` ${binDir}`);
|
|
35
27
|
console.warn("Otherwise, the 'rcodex' command will not be recognized by your terminal.");
|
|
36
28
|
console.warn("======================================================================\n");
|
|
37
29
|
}
|
|
38
|
-
} catch
|
|
39
|
-
//
|
|
30
|
+
} catch {
|
|
31
|
+
// Do not fail installation for a PATH warning.
|
|
40
32
|
}
|