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
Provenance
- Commit
7c66db2- Tree
ee4fbcd- Author
Ken Sato <ksato9700@gmail.com>- Committer
Ken Sato <ksato9700@gmail.com>- Parent
05e95ae
1 file changed+26 added−21 removed
modified:bin/express+26 added-21 removed
6 unmodified lines7 var express = require('../')8 , exec = require('child_process').exec9 , program = require('commander')10 , mkdirp = require('mkdirp')11+ , os = require('os')12 , fs = require('fs');13 14 // CLI15 8 unmodified lines24 // Path25 26 var path = program.args.shift() || '.';27 28+// end-of-line code29+30+var eol = os.platform()=='win32'? '\r\n' : '\n'31+32 // Template engine33 34 program.template = 'jade';35 if (program.ejs) program.template = 'ejs';17 unmodified lines53 , ''54 , 'exports.index = function(req, res){'55 , ' res.render(\'index\', { title: \'Express\' });'56 , '};'52-].join('\r\n');57+].join(eol);58 59 /**60 * Jade layout template.61 */5 unmodified lines67 , ' title= title'68 , ' link(rel=\'stylesheet\', href=\'/stylesheets/style.css\')'69 , ' body'70 , ' block content'66-].join('\r\n');71+].join(eol);72 73 /**74 * Jade index template.75 */3 unmodified lines79 , ''80 , 'block content'81 , ' h1= title'82 , ' p Welcome to #{title}'78-].join('\r\n');83+].join(eol);84 85 /**86 * EJS index template.87 */9 unmodified lines97 , ' <h1><%= title %></h1>'98 , ' <p>Welcome to <%= title %></p>'99 , ' </body>'100 , '</html>'96-].join('\r\n');101+].join(eol);102 103 /**104 * JSHTML layout template.105 */8 unmodified lines114 , ' <body>'115 , ' @write(body)'116 , ' </body>'117 , '</html>'113-].join('\r\n');118+].join(eol);119 120 /**121 * JSHTML index template.122 */123 124 var jshtmlIndex = [125 '<h1>@write(title)</h1>'126 , '<p>Welcome to @write(title)</p>'122- ].join('\r\n');127+ ].join(eol);128 129 /**130 * Default css template.131 */6 unmodified lines138 , ''139 , 'a {'140 , ' color: #00B7FF;'141 , '}'137-].join('\r\n');142+].join(eol);143 144 /**145 * Default less template.146 */6 unmodified lines153 , ''154 , 'a {'155 , ' color: #00B7FF;'156 , '}'152-].join('\r\n');157+].join(eol);158 159 /**160 * Default stylus template.161 */3 unmodified lines165 , ' padding: 50px'166 , ' font: 14px "Lucida Grande", Helvetica, Arial, sans-serif'167 , 'a'168 , ' color: #00B7FF'164-].join('\r\n');169+].join(eol);170 171 /**172 * App template.173 */30 unmodified lines204 , 'http.createServer(app).listen(3000);'205 , ''206 , 'console.log("Express server listening on port 3000");'207 , ''203-].join('\r\n');208+].join(eol);209 210 // Generate application211 212 (function createApplication(path) {65 unmodified lines278 279 // 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 }287 288 // 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 : '');292 293 // Template support294 app = app.replace(':TEMPLATE', program.template);295 296 // 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 += '}';307 308 309 write(path + '/package.json', json);55 unmodified lines