Skip to content

Commit 374ab53

Browse files
committedFeb 18, 2015
using system appropriate newline when modifying files
as discussed in jspm#518
1 parent ef2a0d9 commit 374ab53

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed
 

‎.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto

‎lib/config.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ var mkdirp = require('mkdirp');
2525
var extend = require('./common').extend;
2626
var config = module.exports;
2727
var asp = require('rsvp').denodeify;
28+
var EOL = require('os').EOL;
29+
30+
// default newline to the appropriate value for the system
31+
config.newLine = EOL;
2832

2933
// given a package.json file and an override
3034
// calculate the package.json file jspm will see

‎lib/config/loader.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -322,24 +322,24 @@ Config.prototype.write = function() {
322322
delete cfg.bundles;
323323

324324
if (hasProperties(cfg))
325-
configContent += 'System.config(' + JSON.stringify(cfg, null, 2) + ');\n\n';
325+
configContent += 'System.config(' + JSON.stringify(cfg, null, 2) + ');' + config.newLine + config.newLine;
326326

327327
cfg.meta = meta;
328328
cfg.depCache = depCache;
329329
cfg.map = map;
330330
cfg.versions = versions;
331331

332332
if (hasProperties(meta))
333-
configContent += 'System.config(' + JSON.stringify({ meta: meta }, null, 2) + ');\n\n';
333+
configContent += 'System.config(' + JSON.stringify({ meta: meta }, null, 2) + ');' + config.newLine + config.newLine;
334334

335335
if (hasProperties(depCache))
336-
configContent += 'System.config(' + JSON.stringify({ depCache: depCache }, null, 2) + ');\n\n';
336+
configContent += 'System.config(' + JSON.stringify({ depCache: depCache }, null, 2) + ');' + config.newLine + config.newLine;
337337

338338
if (hasProperties(map))
339-
configContent += 'System.config(' + JSON.stringify({ map: map }, null, 2) + ');\n\n';
339+
configContent += 'System.config(' + JSON.stringify({ map: map }, null, 2) + ');' + config.newLine + config.newLine;
340340

341341
if (hasProperties(versions))
342-
configContent += 'System.config(' + JSON.stringify({ versions: versions }, null, 2) + ');\n\n';
342+
configContent += 'System.config(' + JSON.stringify({ versions: versions }, null, 2) + ');' + config.newLine + config.newLine;
343343

344344
return asp(fs.writeFile)(this.fileName_, configContent);
345345
}

‎lib/config/package.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ PackageJSON.prototype.write = function() {
209209
}
210210

211211
// NB check that the file hasn't changed since we opened it and if so, prompt
212-
return asp(fs.writeFile)(this.fileName, JSON.stringify(this.originalPjson, null, 2) + '\n');
212+
return asp(fs.writeFile)(this.fileName, JSON.stringify(this.originalPjson, null, 2) + config.newLine);
213213
}
214214

215215
// can take an existing non-jspm package.json

0 commit comments

Comments
 (0)
Please sign in to comment.