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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticore-api-gateway",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "OptiCore API Gateway",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -15,13 +15,16 @@
15
15
  const fs = require('fs');
16
16
  const path = require('path');
17
17
 
18
- // When installed as a dependency, process.cwd() is the consumer project root.
19
- // When running in the package's own dev install, skip everything.
20
- const projectRoot = process.cwd();
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 itself — nothing to do
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