Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaning up some sake stuff and added test coverage
  • Loading branch information
matthewrobb committed Aug 27, 2012
1 parent 67025e8 commit 81fe718
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .coverignore
@@ -0,0 +1,3 @@
index.js
lib/esprima.js
test/test.js
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,2 +1,5 @@
/.coverage_data
/cover_html
/node_modules
/*.sublime-*
.DS_Store
47 changes: 31 additions & 16 deletions Sakefile
@@ -1,18 +1,33 @@
task('default', (t) => {
console.log('Please specify a task.');
t.done();
});

task('test', (t) => {
sh('node node_modules/mocha/bin/mocha', function(err, result){
console.log(result);
t.done();
});
});
import { exec } from "child_process";

task('compile', (t) => {
sh('node bin/six -co ./lib ./src', function(err, result){
console.log(result);
t.done();
});
});
var launch = (cmd, callback) => {
var child = exec(cmd, callback)
child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
}

task('default', t => {
console.log('Please specify a task.')
t.done()
})

task('test', t => {
launch('node node_modules/mocha/bin/mocha', () => t.done())
})

task('compile', t => {
launch('node bin/six -co ./lib ./src', () => t.done())
})

task('cover', t => {
launch('node node_modules/cover/bin/cover run node_modules/mocha/bin/_mocha', () => {
launch('node node_modules/cover/bin/cover report html')
launch('node node_modules/cover/bin/cover report cli')
t.done()
})
})

task('watch', t => {
launch('node bin/six -cwo ./lib ./src', () => t.done())
})
22 changes: 9 additions & 13 deletions bin/sake
@@ -1,21 +1,17 @@
#!/usr/bin/env node

var path = require('path');
var fs = require('fs');
var readFileSync = fs.readFileSync;
var path = require('path')
var fs = require('fs')
var readFileSync = fs.readFileSync

var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
var Sakefile = fs.realpathSync('./Sakefile');
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib')
var tasks = fs.realpathSync('./Sakefile')

var six = require(lib + '/six');
var cli = require(lib + '/../node_modules/sake/node_modules/sake/cli-app');
var six = require(lib + '/six')

fs.readFileSync = function(file, enc){
fs.readFileSync = function(file, enc) {
var ret = readFileSync(file, enc);
if(file === Sakefile){
ret = six.compile(ret);
}
return ret;
return file === tasks ? six.compile(ret, {style: 'node', module: 'Sakefile'}) : ret
}

cli.run();
require(lib + '/../node_modules/sake/node_modules/sake/cli-app').run()
3 changes: 0 additions & 3 deletions lib/command.js
Expand Up @@ -125,9 +125,6 @@ function timeLog(message) {






module.exports = {
run: run
};
6 changes: 3 additions & 3 deletions lib/six.js
Expand Up @@ -3,13 +3,13 @@ var fs = require('fs');
var harmonizr = require('./harmonizr');
var esprima = require('./esprima');

var parse = esprima.parse
var parse = esprima.parse;
var Syntax = esprima.Syntax;

var harmonize = harmonizr.harmonize;
var modulesStyles = harmonizr.harmonize;
var modulesStyles = harmonizr.modulesStyles;

function compile(src, options) {
var compile = function(src, options) {
options = options || { style: 'node' }
src = harmonize(src, options);
return src;
Expand Down
1 change: 0 additions & 1 deletion lib/test.js

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -27,6 +27,7 @@
"devDependencies" : {
"mocha" : "",
"chai" : "",
"should" : ""
"should" : "",
"cover" : ""
}
}
3 changes: 0 additions & 3 deletions src/command.js
Expand Up @@ -123,6 +123,3 @@ function timeLog(message) {
console.log((new Date).toLocaleTimeString() + ' - ' + message)
}




6 changes: 3 additions & 3 deletions src/six.js
Expand Up @@ -3,13 +3,13 @@ module fs = "fs";
module harmonizr = "./harmonizr";
module esprima = "./esprima";

var parse = esprima.parse
var parse = esprima.parse;
var Syntax = esprima.Syntax;

export var harmonize = harmonizr.harmonize;
export var modulesStyles = harmonizr.harmonize;
export var modulesStyles = harmonizr.modulesStyles;

export function compile(src, options) {
export var compile = (src, options) => {
options = options || { style: 'node' }
src = harmonize(src, options);
return src;
Expand Down

0 comments on commit 81fe718

Please sign in to comment.