Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: bc0385c668
Fetching contributors…

Cannot retrieve contributors at this time

executable file 51 lines (38 sloc) 1.304 kB
#!/usr/bin/env node
var fs = require("fs"),
colors = require("colors"),
cp = require("child_process"),
_ = require("underscore"),
exec = cp.exec,
args = process.argv.slice(2),
spec, path;
if ( !args.length ) {
console.log( "Please specify a new test 'spec' to create." );
process.exit();
}
spec = (args[ 0 ]).trim();
path = "tests/" + spec;
fs.readdir( path, function( err, files ) {
if ( err !== null && !/No such file/.test(err) ) {
exec( "cp -r tests/boilerplate/ " + path, function( err, stdout, stderr ) {
if ( err === null ) {
console.log( "Copied!".green );
fs.readdir( path, function( err, files ) {
files.forEach(function( file ) {
var target = path + "/" + file,
source = fs.readFileSync( target ).toString(),
out = fs.openSync( target, "w+" ),
title = spec.split("-").map(function(val) {
return val[0].toUpperCase() + val.slice(1);
}).join(" ");
spec
fs.writeSync( out, _.template( source, { spec: spec, title: title }) );
});
console.log( "Configured!".green );
});
}
});
} else {
console.log( ("Directory: " + path + " already exists").red );
}
});
Jump to Line
Something went wrong with that request. Please try again.