From c7d46270aca83ecfe78f69fa923bc574c0b5bfdc Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Sat, 16 Nov 2013 13:21:27 -0800 Subject: [PATCH] feat: remove `karma` binary in favor of karma-cli BREAKING CHANGE: The `karma` module does not export `karma` binary anymore. The recommended way is to have local modules (karma and all the plugins that your project needs) stored in your `package.json`. You can run that particular Karma by `./node_modules/karma/bin/karma`. Or you can have `karma-cli` installed globally on your system, which enables you to use the `karma` command. The global `karma` command (installed by `karma-cli`) does look for local version of Karma (including parent directories) first and fall backs to a global one. The `bin/karma` binary does not look for any other instances of Karma and just runs the one that it belongs to. --- bin/karma | 29 +---------------------------- lib/cli.js | 21 +++++++++++++++++++++ package.json | 4 +--- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/bin/karma b/bin/karma index 5c55decf9..19bb1e350 100755 --- a/bin/karma +++ b/bin/karma @@ -1,30 +1,3 @@ #!/usr/bin/env node -var path = require('path'); -var fs = require('fs'); - -// Try to find a local install -var dir = path.resolve(process.cwd(), 'node_modules', 'karma', 'lib'); - -// Check if the local install exists else we use the install we are in -if (!fs.existsSync(dir)) { - dir = path.join('..', 'lib'); -} - -var cli = require(path.join(dir, 'cli')); -var config = cli.process(); - -switch (config.cmd) { - case 'start': - require(path.join(dir, 'server')).start(config); - break; - case 'run': - require(path.join(dir, 'runner')).run(config); - break; - case 'init': - require(path.join(dir, 'init')).init(config); - break; - case 'completion': - require(path.join(dir, 'completion')).completion(config); - break; -} +require('../lib/cli').run(); diff --git a/lib/cli.js b/lib/cli.js index 6bed21c15..655c797df 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -215,6 +215,27 @@ exports.process = function() { return processArgs(argv, options, fs, path); }; + +exports.run = function() { + var config = exports.process(); + + switch (config.cmd) { + case 'start': + require('./server').start(config); + break; + case 'run': + require('./runner').run(config); + break; + case 'init': + require('./init').init(config); + break; + case 'completion': + require('./completion').completion(config); + break; + } +}; + + // just for testing exports.processArgs = processArgs; exports.parseClientArgs = parseClientArgs; diff --git a/package.json b/package.json index 048bfd3ca..6e8bb33e7 100644 --- a/package.json +++ b/package.json @@ -164,9 +164,7 @@ "grunt-browserify": "~1.2.4" }, "main": "./lib/index", - "bin": { - "karma": "./bin/karma" - }, + "bin": {}, "engines": { "node": "~0.8 || ~0.10" },