diff --git a/tools/bundler.js b/tools/bundler.js index 72e91650a0..9f397ae45d 100644 --- a/tools/bundler.js +++ b/tools/bundler.js @@ -150,10 +150,9 @@ _.extend(PackageBundlingInfo.prototype, { // found in this package. We'll use handlers that are defined in // this package and in its immediate dependencies. ('extension' // should be the extension of the file without a leading dot.) - get_source_handler: function (filepath) { + get_source_handler: function (extension) { var self = this; var candidates = []; - var extension = files.extname(filepath); if (extension in self.pkg.extensions) candidates.push(self.pkg.extensions[extension]); @@ -188,9 +187,9 @@ _.extend(PackageBundlingInfo.prototype, { return; self.files[where][rel_path] = true; - var handler = self.get_source_handler(rel_path); - - if (!! handler) { + var ext = files.findExtension(self.api.registered_extensions(), rel_path); + var handler = ext && self.get_source_handler(ext.substr(1)); + if (handler) { handler(self.bundle.api, path.join(self.pkg.source_root, rel_path), path.join(self.pkg.serve_root, rel_path), diff --git a/tools/files.js b/tools/files.js index ce37e31282..ac737c9fcb 100644 --- a/tools/files.js +++ b/tools/files.js @@ -85,7 +85,7 @@ var files = module.exports = { extensions, func); }); }); - } else if (!! files.findExtension(extensions, filepath)) { + } else if (files.findExtension(extensions, filepath)) { func(filepath); } }); @@ -101,7 +101,7 @@ var files = module.exports = { ret = ret.concat(files.file_list_sync( path.join(filepath, fileName), extensions)); }); - } else if (!! files.findExtension(extensions, filepath)) { + } else if (files.findExtension(extensions, filepath)) { ret.push(filepath); } @@ -109,25 +109,16 @@ var files = module.exports = { }, // given a list of extensions and a path, return the file extension - // provided in the list. If it doesn't find it, return false. + // provided in the list. If it doesn't find it, return null. findExtension: function (extensions, filepath) { var len = filepath.length; for (var i = 0; i < extensions.length; ++i) { - ext = extensions[i]; + var ext = extensions[i]; if (filepath.indexOf(ext, len - ext.length) !== -1){ return ext; } } - return false; - }, - - // given a path, return his file extension, unlike the node native - // `path.extname` function, this function support multiple extensions - // such as `.coffee.md`. false otherwise. - extname: function (filepath) { - var basename = path.basename(filepath); - - return basename.substring(basename.indexOf('.') + 1); + return null; }, // given a path, returns true if it is a meteor application (has a diff --git a/tools/run.js b/tools/run.js index 18beb467db..e9e1a14e09 100644 --- a/tools/run.js +++ b/tools/run.js @@ -507,7 +507,7 @@ _.extend(DependencyWatcher.prototype, { // Source files if (in_any_dir(self.source_dirs) && - _.indexOf(self.source_extensions, path.extname(filepath)) !== -1) + files.findExtension(self.source_extensions, filepath)) return true; // Other directories and files that are included