You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-3Lines changed: 39 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,21 @@
2
2
3
3
A replacement for process.exit that ensures stdio are fully drained before exiting.
4
4
5
-
If you're familiar with the seemingly never-ending saga in joyent/node#3584, you already know that Node.js behaves differently on Windows when pipe-redirecting `stdout` or `stderr` vs just displaying output in the shell. Well, this module attempts to work around the issue by waiting until those streams have been completely drained before actually calling `process.exit`.
5
+
To make a long story short, if `process.exit` is called on Windows, script output is often truncated when pipe-redirecting `stdout` or `stderr`. This module attempts to work around this issue by waiting until those streams have been completely drained before actually calling `process.exit`.
6
6
7
-
Based on some code by @vladikoff.
7
+
See [Node.js issue #3584](https://github.com/joyent/node/issues/3584) for further reference.
8
+
9
+
Tested in OS X 10.8, Windows 7 on Node.js 0.8.25 and 0.10.18.
10
+
11
+
Based on some code by [@vladikoff](https://github.com/vladikoff).
8
12
9
13
## Getting Started
10
14
Install the module with: `npm install exit`
11
15
12
16
```javascript
13
17
var exit =require('exit');
14
18
15
-
// These lines should appear in the output.
19
+
// These lines should appear in the output, EVEN ON WINDOWS.
16
20
console.log("foo");
17
21
console.error("bar");
18
22
@@ -24,6 +28,38 @@ console.log("foo");
24
28
console.error("bar");
25
29
```
26
30
31
+
## Don't believe me? Try it for yourself.
32
+
33
+
In Windows, clone the repo and cd to the `test\fixtures` directory. The only difference between [log.js](test/fixtures/log.js) and [log-broken.js](test/fixtures/log-broken.js) is that the former uses `exit` while the latter calls `process.exit` directly.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
0 commit comments