Merge pull request #1073 from Zoramite/lessMiddleware
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Adding support back in for less CSS.
authored by TJ Holowaychuk · committed by TJ Holowaychuk · parents 377677c, 4c1afb2 · Browse files · 1 file·+20 added−10 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+20 added−10 removed
- other:+20 added−10 removed
Provenance
- Commit
f1d759f- Tree
83ed55e- Author
TJ Holowaychuk <tj@vision-media.ca>- Committer
TJ Holowaychuk <tj@vision-media.ca>- Parent 1
377677c- Parent 2
4c1afb2
1 file changed+20 added−10 removed
modified:bin/express+20 added-10 removed
16 unmodified lines17 .version(express.version)18 .option('-s, --sessions', 'add session support')19 .option('-e, --ejs', 'add ejs engine support (defaults to jade)')20 .option('-J, --jshtml', 'add jshtml engine support (defaults to jade)')21- .option('-S, --stylus', 'add stylus support')21+ .option('-c, --css <engine>', 'add stylesheet <engine> support (less|stylus) (defaults to plain css)')22 .option('-f, --force', 'force on non-empty directory')23 .parse(process.argv);24 25 // Path9 unmodified lines35 program.template = 'jade';36 if (program.ejs) program.template = 'ejs';37 if (program.jshtml) program.template = 'jshtml';38 39-// Stylesheet engine40-41-program.css = program.stylus42- ? 'stylus'43- : null;44-39 /**40 * Routes index template.41 */42 139 unmodified lines182 , 'app.configure(function(){'183 , ' app.set(\'views\', __dirname + \'/views\');'184 , ' app.set(\'view engine\', \':TEMPLATE\');'185 , ' app.use(express.favicon());'192- , ' app.use(express.logger(\'dev\'));'186+ , ' app.use(express.logger(\'dev\'));{css}'187 , ' app.use(express.static(__dirname + \'/public\'));'188 , ' app.use(express.bodyParser());'195- , ' app.use(express.methodOverride());{sess}{css}'189+ , ' app.use(express.methodOverride());{sess}'190 , ' app.use(app.router);'191 , '});'192 , ''193 , 'app.configure(\'development\', function(){'50 unmodified lines244 mkdir(path + '/public/javascripts');245 mkdir(path + '/public/images');246 mkdir(path + '/public/stylesheets', function(){247 switch (program.css) {248+ case 'less':249+ write(path + '/public/stylesheets/style.less', less);250+ break;251 case 'stylus':252 write(path + '/public/stylesheets/style.styl', stylus);253 break;254 default:23 unmodified lines278 });279 280 // CSS Engine support281 switch (program.css) {282+ case 'less':283+ app = app.replace('{css}', eol + ' app.use(require(\'less-middleware\')({ src: __dirname + \'/public\' }));');284+ break;285 case 'stylus':286 app = app.replace('{css}', eol + ' app.use(require(\'stylus\').middleware({ src: __dirname + \'/public\' }));');287 break;288 default:18 unmodified lines307 express: express.version308 }309 }310 311- if (program.css) pkg.dependencies[program.css] = '*';311 if (program.template) pkg.dependencies[program.template] = '*';312 313+ // CSS Engine support314+ switch (program.css) {315+ case 'less':316+ pkg.dependencies['less-middleware'] = '*';317+ break;318+ default:319+ if(program.css) {320+ pkg.dependencies[program.css] = '*';321+ }322+ }323+324 write(path + '/package.json', JSON.stringify(pkg, null, 2));325 write(path + '/app.js', app);326 });327 }52 unmodified lines