Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move test script to package.json, remove setup.js

  • Loading branch information...
commit d34a529476316f07c799976f44a8b8b74b002226 1 parent 8e7ad68
@isaacs isaacs authored
Showing with 1 addition and 66 deletions.
  1. +1 −1  package.json
  2. +0 −65 setup.js
View
2  package.json
@@ -30,7 +30,7 @@
},
"scripts": {
"prepublish": "coffee -o lib/ src/",
- "test": "node setup.js test"
+ "test": "mocha --compilers coffee:coffee-script --require test/common.js --colors"
},
"dependencies": {},
"devDependencies": {
View
65 setup.js
@@ -1,65 +0,0 @@
-var exec = require('child_process').exec;
-var sysPath = require('path');
-var fs = require('fs');
-
-// Cross-platform node.js postinstall & test script for coffeescript projects.
-
-var mode = process.argv[2];
-
-var fsExists = fs.exists || sysPath.exists;
-
-var getBinaryPath = function(binary) {
- return sysPath.join('node_modules', '.bin', binary);
-};
-
-var execute = function(path, params, callback) {
- if (callback == null) callback = function() {};
- var command = 'node ' + path + ' ' + params;
- console.log('Executing', command);
- exec(command, function(error, stdout, stderr) {
- if (error != null) return process.stderr.write(stderr.toString());
- console.log(stdout.toString());
- });
-};
-
-var togglePostinstall = function(add) {
- var pkg = require('./package.json');
-
- if (add) {
- if (!pkg.scripts) pkg.scripts = {};
- pkg.scripts.postinstall = 'node setup.js test';
- } else if (pkg.scripts && pkg.scripts.postinstall) {
- delete pkg.scripts.postinstall;
- }
-
- fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
-};
-
-switch (mode) {
- // Remove `.postinstall` script to prevent stupid npm bugs.
- case 'prepublish':
- togglePostinstall(false);
- execute(getBinaryPath('coffee'), '-o lib/ src/');
- break;
-
- // Bring back `.postinstall` script.
- case 'postpublish':
- togglePostinstall(true);
- break;
-
- // Compile coffeescript for git users.
- case 'postinstall':
- fsExists(sysPath.join(__dirname, 'lib'), function(exists) {
- if (exists) return;
- execute(getBinaryPath('coffee'), '-o lib/ src/');
- });
- break;
-
- // Run tests.
- case 'test':
- execute(
- getBinaryPath('mocha'),
- '--compilers coffee:coffee-script --require test/common.js --colors'
- );
- break;
-}
Please sign in to comment.
Something went wrong with that request. Please try again.