Skip to content
Myr

App generation in bin/express

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 3056369 · Browse files · 1 file+44 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+44 added−2 removed

  • other:+44 added−2 removed

1 file+44 added−2 removed

modified:bin/express+44 added-2 removed
2 unmodified lines
3/**4 * Module dependencies.5 */67var sys = require('sys');7var sys = require('sys'),8 fs = require('fs'),9 childProcess = require('child_process');1011/**12 * Framework version.13 */
12 unmodified lines
26 + ' -h, --help Output help information\n'2728// Parse arguments2928var args = process.argv.slice(2);30var args = process.argv.slice(2),31 path = '.';32while (args.length) {33 var arg = args.shift();34 switch (arg) {35 case '-h':
3 unmodified lines
39 case '-v':40 case '--version':41 abort(version);42 break;43 default:44 path = arg;45 }46}4748// Generate application4950(function createApplication(path) {51 mkdir(path, function(){52 write(path + '/app.js', 'app contents');53 mkdir(path + '/config');54 mkdir(path + '/views/partials');55 });56})(path);5758/**59 * echo str > path.60 *61 * @param {String} path62 * @param {String} str63 */6465function write(path, str) {66 fs.writeFile(path, str);67 sys.puts(' create : ' + path);68}6970/**71 * Mkdir -p.72 *73 * @param {String} path74 * @param {Function} fn75 */7677function mkdir(path, fn) {78 childProcess.exec('mkdir -p ' + path, function(err){79 if (err) throw err;80 sys.puts(' create : ' + path);81 fn && fn();82 });83}8485/**86 * Exit with the given `str`.87 *88 * @param {String} str89 */
5 unmodified lines