From b1c3dc40bde25434e8df10a8097db0785758b6d8 Mon Sep 17 00:00:00 2001 From: estark37 Date: Thu, 16 May 2013 19:16:43 -0700 Subject: [PATCH] Fix addAssetDir bugs One bug (I think) was the the assetPath argument to walk() was getting stomped on and therefore not being used, so I removed the argument. Another bug was that the url for an asset was being set from the file's absolute path. --- tools/bundler.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tools/bundler.js b/tools/bundler.js index d8df071b12..f1d640faa1 100644 --- a/tools/bundler.js +++ b/tools/bundler.js @@ -664,10 +664,8 @@ _.extend(ClientTarget.prototype, { // Add all of the files in a directory `rootDir` (and its // subdirectories) as static assets. `rootDir` should be an absolute // path. Only makes sense on clients. If provided, exclude is an - // array of filename regexps to exclude. If provided, assetPath is a - // prefix to use when computing the path for each file in the - // client's asset tree. - addAssetDir: function (rootDir, exclude, assetPathPrefix) { + // array of filename regexps to exclude. + addAssetDir: function (rootDir, exclude) { var self = this; exclude = exclude || []; @@ -676,7 +674,7 @@ _.extend(ClientTarget.prototype, { exclude: exclude }; - var walk = function (dir, assetPath) { + var walk = function (dir) { _.each(fs.readdirSync(dir), function (item) { // Skip excluded files var matchesAnExclude = _.any(exclude, function (pattern) { @@ -686,20 +684,20 @@ _.extend(ClientTarget.prototype, { return; var absPath = path.resolve(dir, item); - assetPath = path.join(dir, item); + var assetPath = path.join(dir, item); if (fs.statSync(absPath).isDirectory()) { - walk(absPath, assetPath); + walk(absPath); return; } var f = new File({ sourcePath: absPath }); - f.setUrlFromRelPath(assetPath); + f.setUrlFromRelPath(path.relative(rootDir, absPath)); self.dependencyInfo.files[absPath] = f.hash(); self.static.push(f); }); }; - walk(rootDir, assetPathPrefix || ''); + walk(rootDir); }, assignTargetPaths: function () {