Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

split command line code out of testrunner and move to cli module

  • Loading branch information...
commit c999ec3cc3953f2a0fd986047d863c59607ce830 1 parent a18102c
@caolan caolan authored
View
2  Makefile
@@ -20,7 +20,7 @@ stamp-build: $(wildcard deps/* lib/*.js)
mkdir -p $(BUILDDIR)/nodeunit
cp -R deps lib/*.js $(BUILDDIR)/nodeunit
find $(BUILDDIR)/nodeunit/ -type f | xargs sed -i 's/\.\.\/deps/.\/deps/'
- printf '#!/bin/sh\n$(NODEJS) $(NODEJSLIBDIR)/$(PACKAGE)/testrunner.js $$@' > $(BUILDDIR)/nodeunit.sh
+ printf '#!/bin/sh\n$(NODEJS) $(NODEJSLIBDIR)/$(PACKAGE)/cli.js $$@' > $(BUILDDIR)/nodeunit.sh
printf "module.exports = require('$(PACKAGE)/nodeunit')" > $(BUILDDIR)/nodeunit.js
test:
View
3  bin/nodeunit
@@ -1,3 +0,0 @@
-#!/bin/sh
-REALPATH=`readlink -f $0`
-node `dirname $REALPATH`/../lib/testrunner.js $@
View
21 lib/cli.js
@@ -0,0 +1,21 @@
+var testrunner = require('./testrunner'),
+ fs = require('fs');
+
+require.paths.push(process.cwd());
+var args = process.ARGV.slice(2);
+
+// load package.json and read version number
+if (args.length === 1 && (args[0] === '-v' || args[0] === '--version')) {
+ fs.readFile(__dirname + '/../package.json', function (err, content) {
+ if (err) {
+ throw err;
+ }
+ else {
+ var pkg = JSON.parse(content);
+ console.log(pkg.version);
+ }
+ });
+ return;
+}
+
+testrunner.run(args);
View
23 lib/testrunner.js
@@ -9,7 +9,6 @@
*/
var nodeunit = require('./nodeunit'),
- fs = require('fs'),
sys = require('sys'),
path = require('path');
@@ -75,25 +74,3 @@ exports.run = function (files) {
}
});
};
-
-// If this is run from the command-line:
-if (module.id === '.') {
- require.paths.push(process.cwd());
- var args = process.ARGV.slice(2);
-
- // load package.json and read version number
- if (args.length === 1 && (args[0] === '-v' || args[0] === '--version')) {
- fs.readFile(__dirname + '/../package.json', function (err, content) {
- if (err) {
- throw err;
- }
- else {
- var pkg = JSON.parse(content);
- console.log(pkg.version);
- }
- });
- return;
- }
-
- exports.run(args);
-}
View
4 package.json
@@ -2,7 +2,7 @@
, "description": "Easy unit testing in node.js, loosely based on the QUnit API"
, "main": "./index"
, "author": "Caolan McMahon"
-, "version": "0.2.2"
+, "version": "0.2.3"
, "repository" :
{ "type" : "git"
, "url" : "http://github.com/caolan/nodeunit.git"
@@ -13,5 +13,5 @@
, "url" : "http://github.com/caolan/nodeunit/raw/master/LICENSE"
}
]
- , "bin" : { "nodeunit" : "./lib/testrunner.js" }
+ , "bin" : { "nodeunit" : "./lib/cli.js" }
}
Please sign in to comment.
Something went wrong with that request. Please try again.