cap-copilot-widget 0.1.5 → 0.1.6
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 -4
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -4,13 +4,25 @@ const path = require("path");
|
|
|
4
4
|
|
|
5
5
|
if (process.env.BTP_COPILOT_SKIP_POSTINSTALL === "1") process.exit(0);
|
|
6
6
|
|
|
7
|
-
const appRoot = process.env.INIT_CWD;
|
|
8
|
-
|
|
9
7
|
const isInstalledPackage = __dirname.includes("node_modules");
|
|
10
|
-
if (!
|
|
11
|
-
|
|
8
|
+
if (!isInstalledPackage) process.exit(0);
|
|
9
|
+
|
|
10
|
+
function findAppRoot() {
|
|
11
|
+
const fromEnv =
|
|
12
|
+
process.env.INIT_CWD ||
|
|
13
|
+
process.env.npm_config_local_prefix;
|
|
14
|
+
if (fromEnv) return fromEnv;
|
|
15
|
+
|
|
16
|
+
const parts = __dirname.split(path.sep);
|
|
17
|
+
const nmIdx = parts.lastIndexOf("node_modules");
|
|
18
|
+
if (nmIdx > 0) return parts.slice(0, nmIdx).join(path.sep);
|
|
19
|
+
|
|
20
|
+
return null;
|
|
12
21
|
}
|
|
13
22
|
|
|
23
|
+
const appRoot = findAppRoot();
|
|
24
|
+
if (!appRoot) process.exit(0);
|
|
25
|
+
|
|
14
26
|
const HTML_CANDIDATES = [
|
|
15
27
|
"index.html",
|
|
16
28
|
"app/index.html",
|