[canviz] r352 committed - Suppress blank line in concatenated path.js for every attempt to inclu...

0 views
Skip to first unread message

can...@googlecode.com

unread,
Jan 31, 2012, 4:28:43 PM1/31/12
to canviz-...@googlegroups.com
Revision: 352
Author: ryandesign.com
Date: Tue Jan 31 13:27:42 2012
Log: Suppress blank line in concatenated path.js for every attempt to
include an already-included file

http://code.google.com/p/canviz/source/detail?r=352

Modified:
/path/trunk/Jakefile

=======================================
--- /path/trunk/Jakefile Sun Jan 29 07:19:14 2012
+++ /path/trunk/Jakefile Tue Jan 31 13:27:42 2012
@@ -16,16 +16,19 @@
function preprocessFile(file) {
var includeFiles = [];
function _preprocessFile(file) {
- if (includeFiles.indexOf(file) !== -1) return '';
includeFiles.push(file);
var lines = fs.readFileSync(file, 'utf8').split("\n");
- lines.forEach(function(line, i) {
- var matches =
/^\s*#include\s*(?:'([^']+)'|"([^"]+)")\s*$/.exec(line);
+ for (var i = 0; i < lines.length; ++i) {
+ var matches =
/^\s*#include\s*(?:'([^']+)'|"([^"]+)")\s*$/.exec(lines[i]);
if (matches) {
var includeFile = path.join(path.dirname(file), matches[1]);
- lines[i] = _preprocessFile(includeFile);
- }
- });
+ if (includeFiles.indexOf(includeFile) === -1) {
+ lines[i] = _preprocessFile(includeFile);
+ } else {
+ lines.splice(i--, 1);
+ }
+ }
+ }
return lines.join("\n");
}
return _preprocessFile(file);

Reply all
Reply to author
Forward
0 new messages