This repository has been archived by the owner on Mar 17, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,749 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
var path = require('path'), | ||
fs = require('fs'); | ||
var binDir = path.dirname(fs.realpathSync(__filename)); | ||
var lib = path.join(binDir, '../lib'); | ||
require.paths.push(lib); | ||
|
||
var jezebel = require(path.join(lib, 'jezebel')); | ||
jezebel.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
watcher = require('jezebel/watcher'), | ||
repl = require('repl'), | ||
childProcess = require('child_process'), | ||
sys = require('sys'); | ||
var binDir = fs.realpathSync(path.dirname(__filename) + '/../bin'); | ||
|
||
var session; | ||
|
||
function evalInRepl(statement) { | ||
process.stdin.emit('data', new Buffer(statement)); | ||
} | ||
|
||
function triggerTestRun() { | ||
evalInRepl("runTests()\n"); | ||
} | ||
|
||
function fileChanged(path, curr, prev) { | ||
if (curr.mtime.getTime() !== prev.mtime.getTime()) { | ||
triggerTestRun(); | ||
} | ||
} | ||
|
||
function runTests() { | ||
// This _should_ work, and would be ideal, but I get very strange behavior | ||
// | ||
// var sandbox = { | ||
// jessie: jessie, | ||
// Buffer: Buffer, | ||
// console: console | ||
// }; | ||
// var script = "jessie.run(['spec'], {format: 'progress'}, function(fail) {console.log(fail);});" | ||
// vm.runInNewContext(script, sandbox, 'jezebel-script'); | ||
|
||
// Running the top level script in a new context is kinda tricky :-( | ||
// | ||
//var scriptFile = binDir + '/jessie'; | ||
//var script = fs.readFileSync(scriptFile).toString(); | ||
//script = script.replace(/#.*/, ''); | ||
//var sandbox = { | ||
// require:require, | ||
// __filename: scriptFile, | ||
// __dirname: binDir, | ||
// process: { | ||
// args: ['spec'], | ||
// cwd: process.cwd, | ||
// on: process.on, | ||
// emit: process.emit | ||
// } | ||
//}; | ||
//vm.runInNewContext(script, sandbox, scriptFile); | ||
|
||
// In process test running. Creates a class reloading problem. :-( | ||
// | ||
//jessie.run(['spec'], {format: 'progress'}, function(fail) { | ||
// process.stdin.emit('data', new Buffer('\n')); | ||
//}) | ||
|
||
// Out of process test running. Prevents direct access to test results :-( | ||
var child = childProcess.spawn(binDir + '/jessie', ['spec']); | ||
child.stdout.addListener("data", function (chunk) { chunk && sys.print(chunk) }); | ||
child.stderr.addListener("data", function (chunk) { chunk && sys.debug(chunk) }); | ||
child.on('exit', function() { evalInRepl("\n") }); | ||
} | ||
|
||
function startRepl() { | ||
session = repl.start("> "); | ||
session.context.runTests = runTests; | ||
} | ||
|
||
// FIXME Hackity, hack, hack. For some reason, this module is not cached. Spying on a copy won't work. | ||
exports.repl = repl; | ||
|
||
exports.runTests = runTests; | ||
exports.fileChanged = fileChanged; | ||
exports.run = function(args, options) { | ||
watcher.watchFiles(process.cwd(), fileChanged); | ||
startRepl(); | ||
triggerTestRun(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var fs = require('fs'); | ||
var fileExtensionPattern = new RegExp(".*\.(js)"); | ||
|
||
function watchGivenFile (watch, callback) { | ||
fs.watchFile(watch, callback); | ||
} | ||
|
||
function watchFiles(path, callback) { | ||
fs.stat(path, function(err, stats){ | ||
if (err) { | ||
sys.error('Error retrieving stats for file: ' + path); | ||
} else { | ||
if (stats.isDirectory()) { | ||
fs.readdir(path, function(err, fileNames) { | ||
if(err) { | ||
sys.puts('Error reading path: ' + path); | ||
} | ||
else { | ||
fileNames.forEach(function (fileName) { | ||
watchFiles(path + '/' + fileName, callback); | ||
}); | ||
} | ||
}); | ||
} else { | ||
if (path.match(fileExtensionPattern)) { | ||
watchGivenFile(path, function (curr, prev) { | ||
callback(path, curr, prev); | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
exports.watchFiles = watchFiles; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.