Skip to content
This repository was archived by the owner on Mar 4, 2022. It is now read-only.

Commit 1ef0be4

Browse files
authored
Misc updates: global require, Ctrl-c + SIGINT (#105)
- Add the `node_modules` directory from wherever `nodejs-dashboard` is installed to `NODE_PATH` so that the portion of the instructions `<SNIPPED> -- node -r nodejs-dashboard <SNIPPED>` works. Fixes #90 - Use SIGINT for Ctrl-c. Replaces and closes #93
1 parent 73f8f3f commit 1ef0be4

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change log
22

3+
## UNRELEASED
4+
5+
- **Fixed**: Support global installs of `nodejs-dashboard`. Add the `node_modules` directory from wherever `nodejs-dashboard` is installed to `NODE_PATH` to support `node -r nodejs-dashboard` required for full usage. [\#90]
6+
- *Internal*: Use SIGINT for Ctrl-c. [\#93]
7+
38
## [v0.5.0] - 2019-11-21
49

510
- **Breaking**: Update node engines to `8`+
@@ -57,6 +62,7 @@
5762
- *Internal*: Remove dependency on root-require, update repo url in package.json [\#2]
5863
- *Internal*: Test scaffolding and basic reporter integration test [\#3]
5964

65+
[v0.5.0]: https://github.com/FormidableLabs/nodejs-dashboard/compare/v0.4.3...v0.5.0
6066
[v0.4.3]: https://github.com/FormidableLabs/nodejs-dashboard/compare/v0.4.1...v0.4.3
6167
[v0.4.1]: https://github.com/FormidableLabs/nodejs-dashboard/compare/v0.4.0...v0.4.1
6268
[v0.4.0]: https://github.com/FormidableLabs/nodejs-dashboard/compare/v0.3.0...v0.4.0
@@ -66,6 +72,8 @@
6672
[v0.1.2]: https://github.com/FormidableLabs/nodejs-dashboard/compare/v0.1.1...v0.1.2
6773
[v0.1.1]: https://github.com/FormidableLabs/nodejs-dashboard/compare/v0.1.0...v0.1.1
6874

75+
[\#93]: https://github.com/FormidableLabs/nodejs-dashboard/pull/93
76+
[\#90]: https://github.com/FormidableLabs/nodejs-dashboard/issues/90
6977
[\#76]: https://github.com/FormidableLabs/nodejs-dashboard/pull/76
7078
[\#68]: https://github.com/FormidableLabs/nodejs-dashboard/pull/72
7179
[\#67]: https://github.com/FormidableLabs/nodejs-dashboard/pull/70

bin/nodejs-dashboard.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,23 @@ process.env[config.PORT_KEY] = port;
7575
process.env[config.REFRESH_INTERVAL_KEY] = program.refreshinterval;
7676
process.env[config.BLOCKED_THRESHOLD_KEY] = program.eventdelay;
7777

78+
// Enhance `NODE_PATH` to include the dashboard such that `require("nodejs-dashboard")`
79+
// works even if globally installed.
80+
// See: https://github.com/FormidableLabs/nodejs-dashboard/issues/90
81+
const IS_WIN = process.platform.indexOf("win") === 0;
82+
const DELIM = IS_WIN ? ";" : ":";
83+
const DASHBOARD_PATH = path.resolve(__dirname, "../..");
84+
const NODE_PATH = (process.env.NODE_PATH || "")
85+
.split(DELIM)
86+
.filter(Boolean)
87+
.concat(DASHBOARD_PATH)
88+
.join(DELIM);
7889

7990
const child = spawn(command, args, {
80-
env: process.env,
91+
env: {
92+
...process.env,
93+
NODE_PATH
94+
},
8195
stdio: [null, null, null, null],
8296
detached: true
8397
});

lib/dashboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Dashboard.prototype._configureKeys = function () {
5252
// this key will be watched on the global screen
5353
this.screen.ignoreLocked = ["C-c"];
5454
this.screen.key("C-c", () => {
55-
process.exit(0); // eslint-disable-line no-process-exit
55+
process.kill(process.pid, "SIGINT");
5656
});
5757

5858
// watch for key events on the main container; not the screen

0 commit comments

Comments
 (0)