Skip to content
Permalink
Browse files
chore: re-write bash to js.
  • Loading branch information
h13i32maru committed May 9, 2015
1 parent d53c6bf commit edd09cbdf5f4032aa59a5e6e59ab62727475a61a
Showing with 99 additions and 5 deletions.
  1. +5 −5 package.json
  2. +13 −0 script/build.js
  3. +9 −0 script/esdoc-cli.js
  4. +6 −0 script/esdoc.js
  5. +4 −0 script/server.js
  6. +30 −0 script/sh.js
  7. +17 −0 script/test-es5.js
  8. +15 −0 script/test.js
@@ -10,11 +10,11 @@
"url": "https://github.com/h13i32maru/esdoc"
},
"scripts": {
"build": "bash ./script/build.sh",
"test": "bash ./script/test.sh",
"test-es5": "bash ./script/test-es5.sh",
"esdoc": "bash ./script/esdoc.sh",
"start": "bash ./script/server.sh"
"build": "node ./script/build.js",
"test": "node ./script/test.js",
"test-es5": "node ./script/test-es5.js",
"esdoc": "node ./script/esdoc.js",
"start": "node ./script/server.js"
},
"dependencies": {
"babel": "~5.2.9",
@@ -0,0 +1,13 @@
#!/usr/bin/env node
var sh = require('./sh');

sh.rm('./out/src');
sh.mkdir('./out/src');
sh.exec('./node_modules/.bin/babel --out-dir out/src src');
sh.chmod('./out/src/ESDocCLI.js', '755');
sh.cp('./src/Publisher/Builder/template/', './out/src/Publisher/Builder/template/');

// build test
sh.rm('./out/test/src');
sh.mkdir('./out/test/src');
sh.exec('./node_modules/.bin/babel --out-dir out/test/src test/src');
@@ -0,0 +1,9 @@
#!/usr/bin/env node
var path = require('path');
var sh = require('./sh');

var esdoc = path.resolve(__dirname, '..', 'src', 'ESDocCLI.js');
var babel = path.resolve(__dirname, '..', 'node_modules', '.bin', 'babel-node');
var arg = [].concat(process.argv).splice(2);
var cmd = [babel, esdoc].concat(arg).join(' ');
sh.exec(cmd);
@@ -0,0 +1,6 @@
#!/usr/bin/env node
var sh = require('./sh');

sh.rm('./doc/out/esdoc');
sh.mkdir('./doc/out/esdoc');
sh.exec('./node_modules/.bin/babel-node ./src/ESDocCLI.js -c esdoc.json');
@@ -0,0 +1,4 @@
#!/usr/bin/env node
var sh = require('./sh');

sh.exec('./node_modules/.bin/http-server ./ -p 8080 -c -1');
@@ -0,0 +1,30 @@
var fs = require('fs-extra');
var path = require('path');
var child_process = require('child_process');

function rm(path) {
fs.removeSync(path);
}

function mkdir(path) {
fs.mkdirs(path);
}

function exec(cmd) {
cmd = cmd.replace(/\//g, path.sep);
child_process.execSync(cmd, {stdio: 'inherit'});
}

function chmod(path, mode) {
fs.chmodSync(path, mode);
}

function cp(src, dst) {
fs.copySync(src, dst);
}

module.exports.rm = rm;
module.exports.mkdir = mkdir;
module.exports.exec = exec;
module.exports.chmod = chmod;
module.exports.cp = cp;
@@ -0,0 +1,17 @@
#!/usr/bin/env node
var sh = require('./sh');

// judge node or io because run test with node and io on TRAVIS.
// send coverage report with only node.
var isNodeJS = process.version.indexOf('v0.12.') === 0;
var mochaOption=" -t 10000 --recursive ./out/test/src -R spec";

sh.exec('node ./script/build.js');

if (process.env.TRAVIS && isNodeJS) {
sh.exec('./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- ' + mochaOption + ' && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js');
} else if(process.argv.indexOf('--coverage') !== -1) {
sh.exec('./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- ' + mochaOption);
} else {
sh.exec('./node_modules/.bin/mocha' + mochaOption);
}
@@ -0,0 +1,15 @@
#!/usr/bin/env node
var sh = require('./sh');

// judge node or io because run test with node and io on TRAVIS.
// send coverage report with only node.
var isNodeJS = process.version.indexOf('v0.12.') === 0;
var mochaOption=" -t 10000 --require ./node_modules/babel/register.js --recursive ./test/src -R spec";

if (process.env.TRAVIS && isNodeJS) {
sh.exec('./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- ' + mochaOption + ' && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js');
} else if(process.argv.indexOf('--coverage') !== -1) {
sh.exec('./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- ' + mochaOption);
} else {
sh.exec('./node_modules/.bin/mocha' + mochaOption);
}

0 comments on commit edd09cb

Please sign in to comment.