Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
fix: return exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 committed Mar 25, 2014
1 parent 69dea1e commit 0aad62e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
7 changes: 5 additions & 2 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# JS Hint options
JSHINT_BROWSER =
browser: true,
es5: true,
strict: false
undef: false
camelcase: false

JSHINT_NODE =
node: true,
es5: true,
strict: false

module.exports = (grunt) ->
Expand All @@ -20,6 +18,7 @@ module.exports = (grunt) ->

files:
bin: ['bin/*']
lib: ['lib/*']

# JSHint options
# http://www.jshint.com/options/
Expand All @@ -28,6 +27,10 @@ module.exports = (grunt) ->
files:
src: '<%= files.bin %>'
options: JSHINT_NODE
lib:
files:
src: '<%= files.lib %>'
options: JSHINT_NODE

options:
quotmark: 'single'
Expand Down
40 changes: 20 additions & 20 deletions bin/karma
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var path = require('path');
var fs = require('fs');
var resolve = require('resolve');
var info = require('../lib/log');

var NODE_PATH = process.env.NODE_PATH;

Expand All @@ -13,22 +14,6 @@ var NODE_PATH = process.env.NODE_PATH;
// - a siblink module to karma-cli (that loads the global karma, when using NVM),
// - a global module (NODE_PATH)


var requireCliAndRun = function(karmaPath) {
if (process.argv.indexOf('--which') !== -1) {
console.log(karmaPath);
} else {
var karmaCli = require(path.join(karmaPath, 'lib', 'cli'));

if (karmaCli.run) {
karmaCli.run();
} else {
karmaCliRun(karmaCli, karmaPath);
}
}
};


// TODO(vojta): remove once we don't care about Karma 0.10
var karmaCliRun = function(karmaCli, karmaPath) {
var config = karmaCli.process();
Expand All @@ -50,6 +35,21 @@ var karmaCliRun = function(karmaCli, karmaPath) {
};


var requireCliAndRun = function(karmaPath) {
if (process.argv.indexOf('--which') !== -1) {
info.log(karmaPath);
} else {
var karmaCli = require(path.join(karmaPath, 'lib', 'cli'));

if (karmaCli.run) {
karmaCli.run();
} else {
karmaCliRun(karmaCli, karmaPath);
}
}
};


resolve('karma', {basedir: process.cwd()}, function(err, pathToKarma) {
// There is a local version, let's use it.
if (!err) {
Expand All @@ -64,9 +64,9 @@ resolve('karma', {basedir: process.cwd()}, function(err, pathToKarma) {
return requireCliAndRun(siblinkKarma);
}

console.error('Cannot find local Karma!\n' +
info.fatal('Cannot find local Karma!\n' +
' Please install Karma by `npm install karma --save-dev`.\n' +
' If you wanna use a global instance, please set NODE_PATH env variable.\n');
' If you wanna use a global instance, please set NODE_PATH env variable.\n', 1);
return;
}

Expand All @@ -81,6 +81,6 @@ resolve('karma', {basedir: process.cwd()}, function(err, pathToKarma) {
}
}

console.error('Cannot find local Karma!\n' +
' Please install karma by `npm install karma --save-dev`.\n');
info.fatal('Cannot find local Karma!\n' +
' Please install karma by `npm install karma --save-dev`.\n', 1);
});
9 changes: 9 additions & 0 deletions lib/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports.fatal = function(message, code) {
console.error(message);
process.exit(code);
};

exports.log = function(message) {
console.log(message);
process.exit();
};

0 comments on commit 0aad62e

Please sign in to comment.