cap-copilot-sdk 0.2.3 → 0.2.5
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/postinstall.js +16 -5
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -18,13 +18,24 @@ const path = require("path");
|
|
|
18
18
|
// Useful in CI/CD pipelines where package.json is read-only or managed by tooling.
|
|
19
19
|
if (process.env.BTP_COPILOT_SKIP_POSTINSTALL === "1") process.exit(0);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const isInstalledPackage = __dirname.includes("node_modules");
|
|
22
|
+
if (!isInstalledPackage) process.exit(0);
|
|
23
|
+
|
|
24
|
+
function findAppRoot() {
|
|
25
|
+
const fromEnv =
|
|
26
|
+
process.env.INIT_CWD ||
|
|
27
|
+
process.env.npm_config_local_prefix;
|
|
28
|
+
if (fromEnv) return fromEnv;
|
|
29
|
+
const parts = __dirname.split(path.sep);
|
|
30
|
+
const nmIdx = parts.lastIndexOf("node_modules");
|
|
31
|
+
if (nmIdx > 0) return parts.slice(0, nmIdx).join(path.sep);
|
|
32
|
+
|
|
33
|
+
return null;
|
|
26
34
|
}
|
|
27
35
|
|
|
36
|
+
const appRoot = findAppRoot();
|
|
37
|
+
if (!appRoot) process.exit(0);
|
|
38
|
+
|
|
28
39
|
const pkgPath = path.join(appRoot, "package.json");
|
|
29
40
|
if (!fs.existsSync(pkgPath)) process.exit(0);
|
|
30
41
|
|