create add

This commit is contained in:
Peter Cottle 2013-10-26 12:19:25 -07:00
parent cdd93a99e0
commit f1c3ff9e72

View file

@ -6,14 +6,26 @@ prompt = require('prompt');
prompt.start(); prompt.start();
prompt.get(['command'], function(err, result) { prompt.get(['command', 'whatItDoes'], function(err, result) {
var headless = new HeadlessGit(); var headless = new HeadlessGit();
headless.sendCommand(result.command); headless.sendCommand(result.command);
setTimeout(function() { setTimeout(function() {
console.log('expectTreeAsync('); var testCase = '\texpectTreeAsync(' +
console.log(" \t'" + result.command + "',"); "\t\t'" + result.command + "'," +
console.log(" \t'" + headless.gitEngine.printTree() + "'"); "\t\t'" + headless.gitEngine.printTree() + "'" +
console.log(');'); "\t);";
console.log(testCase);
// now add it
var testFile = fs.readFileSync('./remote.spec.js', 'utf8');
// insert after the last })
var toSlice = testFile.lastIndexOf('})');
var partOne = testFile.slice(0, toSlice);
var partTwo = testFile.slice(toSlice);
var funcCall = "it('" + result.whatItDoes + "', function() {\n" +
testCase + "\n});";
fs.writeFileSync('./remote.spec.js', partOne + funcCall + partTwo);
}, 100); }, 100);
}); });