Skip to content
Myr

port some express(1) stuff from 2.x

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 8111a19 · Browse files · 1 file+36 added−20 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+36 added−20 removed

  • other:+36 added−20 removed

1 file+36 added−20 removed

modified:bin/express+36 added-20 removed
13 unmodified lines
1415program16 .version(express.version)17 .option('-s, --sessions', 'add session support')18 .option('-e, --ejs', 'add ejs support (defaults to jade)')19 .option('-J, --jshtml', 'add jshtml support (defaults to jade)')18 .option('-e, --ejs', 'add ejs engine support (defaults to jade)')19 .option('-J, --jshtml', 'add jshtml engine support (defaults to jade)')20 .option('-S, --stylus', 'add stylus support')21 .parse(process.argv);2223// Path
12 unmodified lines
36 ? 'stylus'37 : null;3839/**40 * Routes index template.41 */4243var index = [44 ''45 , '/*'46 , ' * GET home page.'47 , ' */'48 , ''49 , 'exports.index = function(req, res){'50 , ' res.render(\'index\', { title: \'Express\' })'51 , '};'52].join('\n');5354/**55 * Jade layout template.56 */5758var jadeLayout = [
117 unmodified lines
176 , '/**'177 , ' * Module dependencies.'178 , ' */'179 , ''165 , 'var express = require(\'express\');'180 , 'var express = require(\'express\')'181 , ' , routes = require(\'./routes\');'182 , ''183 , 'var app = module.exports = express.createServer();'184 , ''169 , '// Configuration'170 , ''185 , 'app.configure(function(){'186 , ' app.set(\'views\', __dirname + \'/views\');'187 , ' app.set(\'view engine\', \':TEMPLATE\');'188 , ' app.use(express.logger(\'dev\'));'
10 unmodified lines
199 , 'app.configure(\'production\', function(){'200 , ' app.use(express.errorHandler()); '201 , '});'202 , ''189 , '// Routes'203 , 'app.get(\'/\', routes.index);'204 , ''191 , 'app.get(\'/\', function(req, res){'192 , ' res.render(\'index\', {'193 , ' title: \'Express\''194 , ' });'195 , '});'196 , ''205 , 'app.listen(3000);'198 , 'console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);'206 , 'console.log("Express server listening on port %d in %s mode"'207 , ' , app.address().port'208 , ' , app.settings.env);'209 , ''210].join('\n');211212// Generate application
21 unmodified lines
234 * @param {String} path235 */236237function createApplicationAt(path) {238 console.log();239 process.on('exit', function(){240 console.log();241 console.log(' dont forget to install dependencies:');242 console.log(' $ cd %s && npm install', path);243 console.log();244 });245246 mkdir(path, function(){247 mkdir(path + '/public');248 mkdir(path + '/public/javascripts');249 mkdir(path + '/public/images');
1 unmodified line
251 switch (program.css) {252 case 'stylus':253 write(path + '/public/stylesheets/style.styl', stylus);254 break;237 case 'less':238 write(path + '/public/stylesheets/style.less', less);239 break;255 default:256 write(path + '/public/stylesheets/style.css', css);257 }258 });259260 mkdir(path + '/routes', function(){261 write(path + '/routes/index.js', index);262 });263264 mkdir(path + '/views', function(){265 switch (program.template) {266 case 'ejs':267 write(path + '/views/layout.ejs', ejsLayout);
12 unmodified lines
280 });281282 // CSS Engine support283 switch (program.css) {265 case 'less':266 app = app.replace('{css}', '\n app.use(express.compiler({ src: __dirname + \'/public\', enable: [\'' + cssEngine + '\'] }));');267 break;284 case 'stylus':285 app = app.replace('{css}', '\n app.use(require(\'stylus\').middleware({ src: __dirname + \'/public\' }));');286 break;287 default:
1 unmodified line
289 }290291 // Session support292 app = app.replace('{sess}', program.sessions277 ? '\n app.use(express.cookieParser());\n app.use(express.session({ secret: \'your secret here\' }));'293 ? '\n app.use(express.cookieParser(\'your secret here\'));\n app.use(express.session());'294 : '');295296 // Template support297 app = app.replace(':TEMPLATE', program.template);
70 unmodified lines