Skip to content
Myr

Closes #63.

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

Merge branch 'cli'

authored by visionmedia · committed by visionmedia · parents 8dcee4d, d767d80 · Browse files · 2 files+67 added−1 removed
This commit

State

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

Diff stats

2 files+67 added−1 removed

  • other:+67 added−1 removed

2 files+67 added−1 removed

added:bin/express+63 added
1#!/usr/bin/env node23var arg,4 dir = '.',5 fs = require('fs'),6 sys = require('sys'),7 args = process.argv.slice(2)89// Parse arguments1011while (arg = args.shift())12 switch (arg) {13 case '-h':14 case '--help':15 sys.print('Usage: express [options] [dir]\n')16 break17 default:18 dir = arg19 }20 21// Helpers2223function confirm(msg, fn) {24 sys.print(msg)25 process.stdio.open()26 process.stdio.addListener('data', function(chunk){27 switch (chunk.trim().toLowerCase()) {28 case 'yes':29 case 'y':30 return process.stdio.close(),31 fn(true)32 case 'no':33 case 'n':34 return process.stdio.close(),35 fn(false)36 default:37 sys.print(msg)38 }39 })40}4142function createTemplateIn(dir, mode) {43 fs.writeFile(dir + '/app.js', '// your app here')44 fs.mkdir(dir + '/views', mode)45 fs.mkdir(dir + '/public', mode, function(err){46 if (err) throw err47 fs.mkdir(dir + '/public/javascripts', mode)48 fs.mkdir(dir + '/public/stylesheets', mode)49 fs.mkdir(dir + '/public/images', mode)50 })51}5253// Setup template5455fs.readdir(dir, function(err, files){56 if (err) throw err57 if (files.length)58 confirm(dir + ' is not empty, continue? ', function(ok){59 if (ok) createTemplateIn(dir, 0666)60 })61 else62 createTemplateIn(dir, 0666)63})
modified:Makefile+4 added-1 removed
12NODE = node34all: test5 6install: bin/express7 install bin/express /usr/local/bin/express89test:10 @$(NODE) spec/node.js all11
4 unmodified lines
16 17app-upload:18 @$(NODE) examples/upload/app.js19 17.PHONY: test app20.PHONY: install test app