opticore-api-gateway 1.0.2 → 1.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 +8 -5
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -15,13 +15,16 @@
|
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
const path = require('path');
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
18
|
+
// npm runs a dependency's lifecycle scripts with `cwd` set to that package's
|
|
19
|
+
// OWN directory (node_modules/opticore-api-gateway), never the consuming
|
|
20
|
+
// project's root — so process.cwd() can't be used to find the consumer's
|
|
21
|
+
// src/ tree. npm additionally exports INIT_CWD, the directory `npm install`
|
|
22
|
+
// was actually invoked from, which is the value we need here.
|
|
23
|
+
const projectRoot = process.env.INIT_CWD || process.cwd();
|
|
21
24
|
const packageDir = path.resolve(__dirname, '..');
|
|
22
25
|
|
|
23
|
-
if (projectRoot === packageDir) {
|
|
24
|
-
// Running inside the gateway package
|
|
26
|
+
if (path.resolve(projectRoot) === packageDir) {
|
|
27
|
+
// Running inside the gateway package's own dev install — nothing to do
|
|
25
28
|
process.exit(0);
|
|
26
29
|
}
|
|
27
30
|
|