Skip to content

Commit 2989bac

Browse files
author
David Cheung
committed
Revert "Fix process.stdout exiting before done"
This reverts commit 6a8c379.
1 parent abb0de2 commit 2989bac

File tree

4 files changed

+10
-34
lines changed

4 files changed

+10
-34
lines changed

bin/lb-ng.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var SG = require('strong-globalize');
66
SG.SetRootDir(path.resolve(__dirname, '..'));
77
var g = SG();
88
var fs = require('fs');
9-
var Promise = require('bluebird');
109
var semver = require('semver');
1110
var optimist = require('optimist');
1211
var generator = require('loopback-sdk-angular');
@@ -60,17 +59,9 @@ function runGenerator() {
6059
process.stdout.write(result);
6160
}
6261

63-
// The app.js scaffolded by `slc lb project` loads strong-agent module that
64-
// used to have a bug where it prevented the application from exiting.
65-
// To work around that issue, we are explicitly exiting here.
66-
//
67-
// The exit is deferred to both stdout and err is drained
68-
// in order to prevent the Node bug:
62+
// The exit is deferred to the next tick in order to prevent the Node bug:
6963
// https://github.com/joyent/node/issues/3584
70-
Promise.all([
71-
waitForEvent(process.stdout, 'drain'),
72-
waitForEvent(process.stderr, 'drain'),
73-
]).then(function() {
64+
process.nextTick(function() {
7465
process.exit();
7566
});
7667
}
@@ -92,10 +83,3 @@ function assertLoopBackVersion() {
9283
process.exit(1);
9384
}
9485
}
95-
96-
function waitForEvent(obj, name) {
97-
return new Promise(function(resolve, reject) {
98-
obj.once(name, resolve);
99-
obj.once('error', reject);
100-
});
101-
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"node": ">= 0.8.0"
3232
},
3333
"dependencies": {
34-
"bluebird": "^1.2.4",
3534
"loopback-sdk-angular": "^1.8.0",
3635
"optimist": "^0.6.1",
3736
"semver": "^2.2.1",

test/fixtures/app.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ var app = loopback();
1111
// issue where node v6 to chunk output of child_process and
1212
// nextTick exit before finish writing (see PR #45)
1313
app.dataSource('db', {connector: 'memory'});
14-
var User = loopback.createModel('User');
15-
app.model(User, {dataSource: 'db'});
16-
1714
app.set('restApiRoot', '/rest-api-root');
1815

19-
app.dataSource('db', {connector: 'memory'});
16+
var User = loopback.createModel('User');
17+
app.model(User, {dataSource: 'db'});
2018
var TestModel = app.registry.createModel(
2119
'TestModel',
2220
{foobaz: 'string'}

test/lb-ng.test.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('lb-ng', function() {
1717
var sampleAppJs = require.resolve('./fixtures/app.js');
1818
var sampleAsyncAppJs = require.resolve('./fixtures/async-app/app.js');
1919
var SANDBOX = path.resolve(__dirname, 'sandbox');
20+
var tempSDK = path.resolve(SANDBOX, 'lbServices.js');
2021

2122
beforeEach(resetSandbox);
2223

@@ -56,10 +57,11 @@ describe('lb-ng', function() {
5657
});
5758

5859
it('passes the include-schema flag from the command-line', function() {
59-
return runLbNg('-s', sampleAppJs)
60-
.spread(function(script, stderr) {
61-
expect(script).to.contain('R\.schema =');
62-
expect(script).to.contain('schema of the model');
60+
return runLbNg('-s', sampleAppJs, tempSDK)
61+
.spread(function() {
62+
var script = fs.readFileSync(tempSDK);
63+
expect(script).to.match(/R\.schema =/);
64+
expect(script).to.match(/schema of the model/);
6365
});
6466
});
6567

@@ -82,13 +84,6 @@ describe('lb-ng', function() {
8284
});
8385
});
8486

85-
it('does not truncate the output', function() {
86-
return runLbNg(sampleAppJs)
87-
.spread(function(script, stderr) {
88-
expect(script).to.match(/\}\)\(window, window.angular\);/);
89-
});
90-
});
91-
9287
//-- Helpers --
9388

9489
function runLbNg() {

0 commit comments

Comments
 (0)