File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -353,19 +353,16 @@ function prependFile(prefixFile, destinationFile) {
353
353
// concatenate a list of sourceFiles to a destinationFile
354
354
function concatenateFiles ( destinationFile , sourceFiles ) {
355
355
var temp = "temptemp" ;
356
- // Copy the first file to temp
357
- if ( ! fs . existsSync ( sourceFiles [ 0 ] ) ) {
358
- fail ( sourceFiles [ 0 ] + " does not exist!" ) ;
359
- }
360
- jake . cpR ( sourceFiles [ 0 ] , temp , { silent : true } ) ;
361
356
// append all files in sequence
362
- for ( var i = 1 ; i < sourceFiles . length ; i ++ ) {
357
+ var text = "" ;
358
+ for ( var i = 0 ; i < sourceFiles . length ; i ++ ) {
363
359
if ( ! fs . existsSync ( sourceFiles [ i ] ) ) {
364
360
fail ( sourceFiles [ i ] + " does not exist!" ) ;
365
361
}
366
- fs . appendFileSync ( temp , "\n\n" ) ;
367
- fs . appendFileSync ( temp , fs . readFileSync ( sourceFiles [ i ] ) ) ;
362
+ if ( i > 0 ) { text += "\n\n" ; }
363
+ text += fs . readFileSync ( sourceFiles [ i ] ) . toString ( ) . replace ( / \r ? \n / g , "\n" ) ;
368
364
}
365
+ fs . writeFileSync ( temp , text ) ;
369
366
// Move the file to the final destination
370
367
fs . renameSync ( temp , destinationFile ) ;
371
368
}
You can’t perform that action at this time.
0 commit comments