Skip to content

Commit

Permalink
Added error logs for failed webgme start. Fixes #217 (#218)
Browse files Browse the repository at this point in the history
* WIP #217 added test for 'webgme start' error logging

* WIP #217 added failure message on failed 'webgme start'

* WIP #217 tidied up comments and removed extra log

* WIP removed v0.12 from ci and added node 8

* WIP #217 Increased the timeout and improved error msg
  • Loading branch information
brollb committed Nov 10, 2017
1 parent c3f770c commit d07bbd1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ cache:
directories:
- node_modules
node_js:
- "0.12.7"
- "4.1.1"
- "4.2.1"
- "4"
- "6"
- "8"
6 changes: 5 additions & 1 deletion bin/webgme-start
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ program
.parse(process.argv);

if (program.args.length === 0) { // action will not be called
manager.start(program, nop);
manager.start(program, err => {
if (err) {
process.exit(1);
}
});
}
2 changes: 2 additions & 0 deletions src/BaseManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ BaseManager.prototype._start = function (root, callback) {
this._logger.write('Installing dependencies...');
npm.install(err => {
if (err) {
this._logger.error(`Could not install dependencies: ${err.message}`);
return callback(err);
}
if (!exists(webgmePath)) {
this._logger.write('Installing webgme...');
npm.install('webgme', err => {
if (err) {
this._logger.error(`Could not install webgme dependency: ${err.message}`);
return callback(err);
}
npm.start();
Expand Down
31 changes: 29 additions & 2 deletions test-src/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ var testCliCall = function(args, test, done) {
});

webgmeBin.on('exit', function(code) {
assert.equal(code, 0, error);
assert.notEqual(response.length, 0);
if (test) {
test(response, error, done);
} else {
assert.equal(code, 0, error);
assert.notEqual(response.length, 0);
done();
}
});
Expand All @@ -108,6 +108,33 @@ describe('cli', function() {
testCliCall.bind(this, cliCalls[i].split(' '), null));
}

describe('start', function() {
var startProj = path.join(TMP_DIR, 'BaseStartProj');
before(function(done) {
utils.getCleanProject(startProj, done);
});

it('should throw error if deps cannot be installed', function(done) {
let pkgJsonPath = path.join(startProj, 'package.json');
let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
let badPkgName = 'asdfffffffffff';

this.timeout(5000);

// Add a garbage dependency to the package.json
pkgJson.dependencies[badPkgName] = '=12345.0.1.3';
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2));

// Make sure that there are some logs about the error
let testFn = (res, err, done) => {
assert.notEqual(res.indexOf('404'), -1, `Did not print 404 in "${res}"`);
assert.notEqual(res.indexOf(badPkgName), -1);
done();
};
testCliCall(['start'], testFn, done);
});
});

// Checking that 'webgme ls' lists all components
describe('ls', function() {
var lsProject = path.join(TMP_DIR, 'BaseLsProj');
Expand Down

0 comments on commit d07bbd1

Please sign in to comment.