Skip to content
Myr

Added -c, -css ENGINE option to express(1)

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

For example $ express will now just create style.css where as $ express --css sass will generate style.sass for you and setup the compiler middleware etc

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent e09bf5c · Browse files · 2 files+58 added−7 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+58 added−7 removed

  • other:+58 added−7 removed

2 files+58 added−7 removed

modified:bin/express+56 added-6 removed
19 unmodified lines
2021var stdin;2223/**24 * CSS engine to utilize.25 */2627var cssEngine = 'none';2829/**30 * Usage documentation.31 */3233var usage = ''34 + '\x1b[1mUsage\x1b[0m: express [options] [PATH]\n'35 + '\n'36 + '\x1b[1mOptions\x1b[0m:\n'37 + ' -c, --css ENGINE Utilize stylesheet ENGINE (less|sass). Defaults to plain css\n'31 + ' -v, --version Output framework version\n'32 + ' -h, --help Output help information\n';38 + ' -v, --version Output framework version\n'39 + ' -h, --help Output help information\n';4041/**42 * Jade layout template.43 */
7 unmodified lines
51 , ' body!= body'52].join('\n');5354/**55 * Default css template.56 */5758var css = [59 'body {'60 , ' padding: 50px;'61 , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;'62 , '}'63].join('\n');6465/**66 * Default less template.67 */6869var less = [70 'body {'71 , ' padding: 50px;'54 , ' font: 14px "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;'72 , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;'73 , '}'74].join('\n');7576/**77 * Default sass template.78 */7980var sass = [81 'body'82 , ' :padding 50px'83 , ' :font 14px "Lucida Grande", Helvetica, Arial, sans-serif'84].join('\n');8586/**87 * Jade index template.88 */8990var jadeIndex = [
46 unmodified lines
137 , 'app.configure(function(){'138 , ' app.set(\'views\', __dirname + \'/views\');'139 , ' app.set(\'view engine\', \'jade\');'140 , ' app.use(express.bodyDecoder());'113 , ' app.use(express.methodOverride());'114 , ' app.use(express.compiler({ src: __dirname + \'/public\', enable: [\'less\'] }));'141 , ' app.use(express.methodOverride());__CSS__'142 , ' app.use(app.router);'143 , ' app.use(express.staticProvider(__dirname + \'/public\'));'144 , '});'145 , ''
39 unmodified lines
185 case '-v':186 case '--version':187 abort(version);188 break;189 case '-c':190 case '--css':191 args.length192 ? (cssEngine = args.shift())193 : abort('--css requires an argument');194 break;195 default:196 path = arg;197 }198}
29 unmodified lines
228 mkdir(path + '/logs');229 mkdir(path + '/public/javascripts');230 mkdir(path + '/public/images');231 mkdir(path + '/public/stylesheets', function(){232 switch (cssEngine) {233 case 'less':199 write(path + '/public/stylesheets/style.less', less);234 write(path + '/public/stylesheets/style.less', less);235 break;236 case 'sass':237 write(path + '/public/stylesheets/style.sass', sass);238 break;239 default:240 write(path + '/public/stylesheets/style.css', css);241 }242 });243 mkdir(path + '/views/partials', function(){244 write(path + '/views/layout.jade', jadeLayout);245 write(path + '/views/index.jade', jadeIndex);246 });247 mkdir(path + '/test', function(){248 write(path + '/test/app.test.js', appTest);249 });250 switch (cssEngine) {251 case 'sass':252 case 'less':253 app = app.replace('__CSS__', '\n app.use(express.compiler({ src: __dirname + \'/public\', enable: [\'' + cssEngine + '\'] }));');254 break;255 default:256 app = app.replace('__CSS__', '');257 }258 write(path + '/app.js', app);259 });260}261
81 unmodified lines
modified:docs/executable.md+2 added-1 removed