Skip to content
Myr

Change the eol character based on platform type

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

authored by Ken Sato · committed by Ken Sato · parent 05e95ae · Browse files · 1 file+26 added−21 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+26 added−21 removed

  • other:+26 added−21 removed

1 file+26 added−21 removed

modified:bin/express+26 added-21 removed
6 unmodified lines
7var express = require('../')8 , exec = require('child_process').exec9 , program = require('commander')10 , mkdirp = require('mkdirp')11 , os = require('os')12 , fs = require('fs');1314// CLI15
8 unmodified lines
24// Path2526var path = program.args.shift() || '.';2728// end-of-line code2930var eol = os.platform()=='win32'? '\r\n' : '\n'3132// Template engine3334program.template = 'jade';35if (program.ejs) program.template = 'ejs';
17 unmodified lines
53 , ''54 , 'exports.index = function(req, res){'55 , ' res.render(\'index\', { title: \'Express\' });'56 , '};'52].join('\r\n');57].join(eol);5859/**60 * Jade layout template.61 */
5 unmodified lines
67 , ' title= title'68 , ' link(rel=\'stylesheet\', href=\'/stylesheets/style.css\')'69 , ' body'70 , ' block content'66].join('\r\n');71].join(eol);7273/**74 * Jade index template.75 */
3 unmodified lines
79 , ''80 , 'block content'81 , ' h1= title'82 , ' p Welcome to #{title}'78].join('\r\n');83].join(eol);8485/**86 * EJS index template.87 */
9 unmodified lines
97 , ' <h1><%= title %></h1>'98 , ' <p>Welcome to <%= title %></p>'99 , ' </body>'100 , '</html>'96].join('\r\n');101].join(eol);102103/**104 * JSHTML layout template.105 */
8 unmodified lines
114 , ' <body>'115 , ' @write(body)'116 , ' </body>'117 , '</html>'113].join('\r\n');118].join(eol);119120/**121 * JSHTML index template.122 */123124var jshtmlIndex = [125 '<h1>@write(title)</h1>'126 , '<p>Welcome to @write(title)</p>'122 ].join('\r\n');127 ].join(eol);128129/**130 * Default css template.131 */
6 unmodified lines
138 , ''139 , 'a {'140 , ' color: #00B7FF;'141 , '}'137].join('\r\n');142].join(eol);143144/**145 * Default less template.146 */
6 unmodified lines
153 , ''154 , 'a {'155 , ' color: #00B7FF;'156 , '}'152].join('\r\n');157].join(eol);158159/**160 * Default stylus template.161 */
3 unmodified lines
165 , ' padding: 50px'166 , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif'167 , 'a'168 , ' color: #00B7FF'164].join('\r\n');169].join(eol);170171/**172 * App template.173 */
30 unmodified lines
204 , 'http.createServer(app).listen(3000);'205 , ''206 , 'console.log("Express server listening on port 3000");'207 , ''203].join('\r\n');208].join(eol);209210// Generate application211212(function createApplication(path) {
65 unmodified lines
278279 // CSS Engine support280 switch (program.css) {281 case 'stylus':277 app = app.replace('{css}', '\r\n app.use(require(\'stylus\').middleware({ src: __dirname + \'/public\' }));');282 app = app.replace('{css}', eol + ' app.use(require(\'stylus\').middleware({ src: __dirname + \'/public\' }));');283 break;284 default:285 app = app.replace('{css}', '');286 }287288 // Session support289 app = app.replace('{sess}', program.sessions285 ? '\n app.use(express.cookieParser(\'your secret here\'));\n app.use(express.session());'290 ? eol + ' app.use(express.cookieParser(\'your secret here\'));' + eol + ' app.use(express.session());'291 : '');292293 // Template support294 app = app.replace(':TEMPLATE', program.template);295296 // package.json292 var json = '{\n';293 json += ' "name": "application-name"\n';294 json += ' , "version": "0.0.1"\n';295 json += ' , "private": true\n';296 json += ' , "dependencies": {\n';297 json += ' "express": "' + express.version + '"\n';298 if (program.css) json += ' , "' + program.css + '": ">= 0.0.1"\n';299 if (program.template) json += ' , "' + program.template + '": ">= 0.0.1"\n';300 json += ' }\n';297 var json = '{' + eol;298 json += ' "name": "application-name"' + eol;299 json += ' , "version": "0.0.1"' + eol;300 json += ' , "private": true' + eol;301 json += ' , "dependencies": {' + eol;302 json += ' "express": "' + express.version + '"' + eol;303 if (program.css) json += ' , "' + program.css + '": ">= 0.0.1"' + eol;304 if (program.template) json += ' , "' + program.template + '": ">= 0.0.1"' + eol;305 json += ' }' + eol;306 json += '}';307308309 write(path + '/package.json', json);
55 unmodified lines