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
Provenance
- Commit
7bb466d- Tree
c92538c- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
e09bf5c
2 files changed+58 added−7 removed
modified:bin/express+56 added-6 removed
19 unmodified lines20 21 var stdin;22 23 /**24+ * CSS engine to utilize.25+ */26+27+var cssEngine = 'none';28+29+/**30 * Usage documentation.31 */32 33 var 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';40 41 /**42 * Jade layout template.43 */7 unmodified lines51 , ' body!= body'52 ].join('\n');53 54 /**55+ * Default css template.56+ */57+58+var css = [59+ 'body {'60+ , ' padding: 50px;'61+ , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;'62+ , '}'63+].join('\n');64+65+/**66 * Default less template.67 */68 69 var 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');75 76 /**77+ * Default sass template.78+ */79+80+var sass = [81+ 'body'82+ , ' :padding 50px'83+ , ' :font 14px "Lucida Grande", Helvetica, Arial, sans-serif'84+].join('\n');85+86+/**87 * Jade index template.88 */89 90 var jadeIndex = [46 unmodified lines137 , '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 lines185 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 lines228 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 linesmodified:docs/executable.md+2 added-1 removed
12344567891011121314151617
## Synopsis
express [-h|--help] [-v|--version] [PATH] express [-h|--help] [-v|--version] [-c|-css ENGINE] [PATH]
## Description
The `express` executable generates apps at the given **PATH** or the current working directory. Although Express is not bound to a specificapplication structure, this executable creates a maintainable base app.
## Options
-c, --css ENGINE Utilize css ENGINE (less|sass). Defaults to plain css -v, --version Output framework version -h, --help Display help information