1
1
/**
2
- * @license r.js 2.0.2+ Tue, 03 Jul 2012 22:45:51 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 2.0.2+ Wed, 04 Jul 2012 00:44:40 GMT Copyright (c) 2010-2012, 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, existsForNode,
23
- version = '2.0.2+ Tue, 03 Jul 2012 22:45:51 GMT',
23
+ version = '2.0.2+ Wed, 04 Jul 2012 00:44:40 GMT',
24
24
jsSuffixRegExp = /\.js$/,
25
25
commandOption = '',
26
26
useLibLoaded = {},
@@ -2718,6 +2718,31 @@ define('node/file', ['fs', 'path'], function (fs, path) {
2718
2718
fs.unlinkSync(fileName);
2719
2719
}
2720
2720
}
2721
+ },
2722
+
2723
+
2724
+ /**
2725
+ * Deletes any empty directories under the given directory.
2726
+ */
2727
+ deleteEmptyDirs: function (startDir) {
2728
+ var dirFileArray, i, fileName, filePath, stat;
2729
+
2730
+ if (file.exists(startDir)) {
2731
+ dirFileArray = fs.readdirSync(startDir);
2732
+ for (i = 0; i < dirFileArray.length; i++) {
2733
+ fileName = dirFileArray[i];
2734
+ filePath = path.join(startDir, fileName);
2735
+ stat = fs.statSync(filePath);
2736
+ if (stat.isDirectory()) {
2737
+ file.deleteEmptyDirs(filePath);
2738
+ }
2739
+ }
2740
+
2741
+ //If directory is now empty, remove it.
2742
+ if (fs.readdirSync(startDir).length === 0) {
2743
+ file.deleteFile(startDir);
2744
+ }
2745
+ }
2721
2746
}
2722
2747
};
2723
2748
@@ -2735,7 +2760,7 @@ if(env === 'rhino') {
2735
2760
*/
2736
2761
//Helper functions to deal with file I/O.
2737
2762
2738
- /*jslint plusplus: false, strict: false */
2763
+ /*jslint plusplus: false, strict: true */
2739
2764
/*global java: false, define: false */
2740
2765
2741
2766
define('rhino/file', function () {
@@ -2974,6 +2999,35 @@ define('rhino/file', function () {
2974
2999
}
2975
3000
fileObj["delete"]();
2976
3001
}
3002
+ },
3003
+
3004
+ /**
3005
+ * Deletes any empty directories under the given directory.
3006
+ * The startDirIsJavaObject is private to this implementation's
3007
+ * recursion needs.
3008
+ */
3009
+ deleteEmptyDirs: function (startDir, startDirIsJavaObject) {
3010
+ var topDir = startDir,
3011
+ dirFileArray, i, fileObj;
3012
+
3013
+ if (!startDirIsJavaObject) {
3014
+ topDir = new java.io.File(startDir);
3015
+ }
3016
+
3017
+ if (topDir.exists()) {
3018
+ dirFileArray = topDir.listFiles();
3019
+ for (i = 0; i < dirFileArray.length; i++) {
3020
+ fileObj = dirFileArray[i];
3021
+ if (fileObj.isDirectory()) {
3022
+ file.deleteEmptyDirs(fileObj, true);
3023
+ }
3024
+ }
3025
+
3026
+ //If the directory is empty now, delete it.
3027
+ if (topDir.listFiles().length === 0) {
3028
+ file.deleteFile(String(topDir.getPath()));
3029
+ }
3030
+ }
2977
3031
}
2978
3032
};
2979
3033
@@ -14436,6 +14490,12 @@ function (lang, logger, file, parse, optimize, pragma,
14436
14490
});
14437
14491
}
14438
14492
14493
+ //If removeCombined in play, remove any empty directories that
14494
+ //may now exist because of its use
14495
+ if (config.removeCombined && !config.out && config.dir) {
14496
+ file.deleteEmptyDirs(config.dir);
14497
+ }
14498
+
14439
14499
//Do other optimizations.
14440
14500
if (config.out && !config.cssIn) {
14441
14501
//Just need to worry about one JS file.
0 commit comments