Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions bin/lb-ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var SG = require('strong-globalize');
SG.SetRootDir(path.resolve(__dirname, '..'));
var g = SG();
var fs = require('fs');
var Promise = require('bluebird');
var semver = require('semver');
var optimist = require('optimist');
var generator = require('loopback-sdk-angular');
Expand Down Expand Up @@ -60,17 +59,9 @@ function runGenerator() {
process.stdout.write(result);
}

// The app.js scaffolded by `slc lb project` loads strong-agent module that
// used to have a bug where it prevented the application from exiting.
// To work around that issue, we are explicitly exiting here.
//
// The exit is deferred to both stdout and err is drained
// in order to prevent the Node bug:
// The exit is deferred to the next tick in order to prevent the Node bug:
// https://github.com/joyent/node/issues/3584
Promise.all([
waitForEvent(process.stdout, 'drain'),
waitForEvent(process.stderr, 'drain'),
]).then(function() {
process.nextTick(function() {
process.exit();
});
}
Expand All @@ -92,10 +83,3 @@ function assertLoopBackVersion() {
process.exit(1);
}
}

function waitForEvent(obj, name) {
return new Promise(function(resolve, reject) {
obj.once(name, resolve);
obj.once('error', reject);
});
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"node": ">= 0.8.0"
},
"dependencies": {
"bluebird": "^1.2.4",
"loopback-sdk-angular": "^1.8.0",
"optimist": "^0.6.1",
"semver": "^2.2.1",
Expand Down
7 changes: 0 additions & 7 deletions test/fixtures/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@
var loopback = require('loopback');
var app = loopback();

// model creation is added so output has enough content to reproduce
// issue where node v6 to chunk output of child_process and
// nextTick exit before finish writing (see PR #45)
app.dataSource('db', {connector: 'memory'});
var User = loopback.createModel('User');
app.model(User, {dataSource: 'db'});

app.set('restApiRoot', '/rest-api-root');

app.dataSource('db', {connector: 'memory'});
var TestModel = app.registry.createModel(
'TestModel',
{foobaz: 'string'}
Expand Down
17 changes: 6 additions & 11 deletions test/lb-ng.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ describe('lb-ng', function() {
});

it('passes the include-schema flag from the command-line', function() {
return runLbNg('-s', sampleAppJs)
.spread(function(script, stderr) {
expect(script).to.contain('R\.schema =');
expect(script).to.contain('schema of the model');
var outfile = path.resolve(SANDBOX, 'lb-services.js');
return runLbNg('-s', sampleAppJs, outfile)
.spread(function() {
var script = fs.readFileSync(outfile);
expect(script).to.match(/R\.schema =/);
expect(script).to.match(/schema of the model/);
});
});

Expand All @@ -82,13 +84,6 @@ describe('lb-ng', function() {
});
});

it('does not truncate the output', function() {
return runLbNg(sampleAppJs)
.spread(function(script, stderr) {
expect(script).to.match(/\}\)\(window, window.angular\);/);
});
});

//-- Helpers --

function runLbNg() {
Expand Down