1
1
/**
2
- * @license r.js 1.0.2+ 20111222 4:10pm Pacific Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 1.0.2+ 20111222 9:30pm Pacific Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
20
20
21
21
var fileName , env , fs , vm , path , exec , rhinoContext , dir , nodeRequire ,
22
22
nodeDefine , exists , reqMain , loadedOptimizedLib ,
23
- version = '1.0.2+ 20111222 4:10pm Pacific' ,
23
+ version = '1.0.2+ 1.0.2+ 20111222 9:30pm Pacific' ,
24
24
jsSuffixRegExp = / \. j s $ / ,
25
25
commandOption = '' ,
26
26
//Used by jslib/rhino/args.js
@@ -2366,7 +2366,7 @@ define('node/file', ['fs', 'path'], function (fs, path) {
2366
2366
2367
2367
function mkDir ( dir ) {
2368
2368
if ( ! exists ( dir ) ) {
2369
- fs . mkdirSync ( dir , 0777 ) ;
2369
+ fs . mkdirSync ( dir , 511 ) ;
2370
2370
}
2371
2371
}
2372
2372
@@ -2527,6 +2527,13 @@ define('node/file', ['fs', 'path'], function (fs, path) {
2527
2527
return true ; //Boolean
2528
2528
} ,
2529
2529
2530
+ /**
2531
+ * Renames a file. May fail if "to" already exists or is on another drive.
2532
+ */
2533
+ renameFile : function ( from , to ) {
2534
+ return fs . renameSync ( from , to ) ;
2535
+ } ,
2536
+
2530
2537
/**
2531
2538
* Reads a *text* file.
2532
2539
*/
@@ -2763,6 +2770,13 @@ define('rhino/file', function () {
2763
2770
return true ; //Boolean
2764
2771
} ,
2765
2772
2773
+ /**
2774
+ * Renames a file. May fail if "to" already exists or is on another drive.
2775
+ */
2776
+ renameFile : function ( from , to ) {
2777
+ return ( new java . io . File ( from ) ) . renameTo ( ( new java . io . File ( to ) ) ) ;
2778
+ } ,
2779
+
2766
2780
readFile : function ( /*String*/ path , /*String?*/ encoding ) {
2767
2781
//A file read function that can deal with BOMs
2768
2782
encoding = encoding || "utf-8" ;
@@ -8421,9 +8435,22 @@ function (lang, logger, file, parse, optimize, pragma,
8421
8435
8422
8436
//Flatten them and collect the build output for each module.
8423
8437
builtModule = build . flattenModule ( module , module . layer , config ) ;
8424
- file . saveUtf8File ( module . _buildPath , builtModule . text ) ;
8438
+
8439
+ //Save it to a temp file for now, in case there are other layers that
8440
+ //contain optimized content that should not be included in later
8441
+ //layer optimizations. See issue #56.
8442
+ file . saveUtf8File ( module . _buildPath + '-temp' , builtModule . text ) ;
8425
8443
buildFileContents += builtModule . buildText ;
8426
8444
} ) ;
8445
+
8446
+ //Now move the build layers to their final position.
8447
+ modules . forEach ( function ( module ) {
8448
+ var finalPath = module . _buildPath ;
8449
+ if ( file . exists ( finalPath ) ) {
8450
+ file . deleteFile ( finalPath ) ;
8451
+ }
8452
+ file . renameFile ( finalPath + '-temp' , finalPath ) ;
8453
+ } ) ;
8427
8454
}
8428
8455
8429
8456
//Do other optimizations.
0 commit comments