Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 50 lines (38 sloc) 1.299 kb
e505a2a @rwaldron Initial commit
rwaldron authored
1 #!/usr/bin/env node
2 var fs = require("fs"),
3 colors = require("colors"),
4 cp = require("child_process"),
ad5fec1 @rwaldron underscore => lodash
rwaldron authored
5 _ = require("lodash"),
e505a2a @rwaldron Initial commit
rwaldron authored
6 exec = cp.exec,
7
8 args = process.argv.slice(2),
9 spec, path;
10
11
12 if ( !args.length ) {
13 console.log( "Please specify a new test 'spec' to create." );
14 process.exit();
15 }
16
17 spec = (args[ 0 ]).trim();
18 path = "tests/" + spec;
19
20 fs.readdir( path, function( err, files ) {
21
22 if ( err !== null && !/No such file/.test(err) ) {
23 exec( "cp -r tests/boilerplate/ " + path, function( err, stdout, stderr ) {
24
25 if ( err === null ) {
26
27 console.log( "Copied!".green );
28
29 fs.readdir( path, function( err, files ) {
30 files.forEach(function( file ) {
31 var target = path + "/" + file,
32 source = fs.readFileSync( target ).toString(),
33 out = fs.openSync( target, "w+" ),
34 title = spec.split("-").map(function(val) {
35 return val[0].toUpperCase() + val.slice(1);
36 }).join(" ");
37
38 spec
39 fs.writeSync( out, _.template( source, { spec: spec, title: title }) );
40 });
41
42 console.log( "Configured!".green );
43 });
44 }
45 });
46 } else {
47 console.log( ("Directory: " + path + " already exists").red );
48 }
49 });
Something went wrong with that request. Please try again.