From c3e980d8255cef69872b5ca42c53482c54673bb7 Mon Sep 17 00:00:00 2001 From: Nikolaus Graf Date: Wed, 18 May 2011 03:51:30 +0200 Subject: [PATCH] moved generating vendorPath to constructor --- lib/compilers/stitch.js | 14 ++++++-------- src/compilers/stitch.coffee | 13 +++++++------ test/collectDependencies.coffee | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/compilers/stitch.js b/lib/compilers/stitch.js index 0a0125456..44fe7fe50 100644 --- a/lib/compilers/stitch.js +++ b/lib/compilers/stitch.js @@ -17,8 +17,9 @@ Compiler = require('./base').Compiler; exports.StitchCompiler = (function() { __extends(StitchCompiler, Compiler); - function StitchCompiler() { - StitchCompiler.__super__.constructor.apply(this, arguments); + function StitchCompiler(options) { + StitchCompiler.__super__.constructor.call(this, options); + this.vendorPath = path.join(options.brunchPath, 'src/vendor'); } StitchCompiler.prototype.filePattern = function() { return [/\.coffee$/, /src\/.*\.js$/, new RegExp("" + this.options.templateExtension + "$")]; @@ -53,19 +54,16 @@ }; StitchCompiler.prototype.collectDependencies = function() { var additionalLibaries, args, dependencies, filenames; - filenames = fs.readdirSync(this.vendorPath()); - filenames = helpers.filterFiles(filenames, this.vendorPath()); + filenames = fs.readdirSync(this.vendorPath); + filenames = helpers.filterFiles(filenames, this.vendorPath); args = this.options.dependencies.slice(); args.unshift(filenames); additionalLibaries = _.without.apply(this, args); dependencies = this.options.dependencies.concat(additionalLibaries); return _.map(dependencies, __bind(function(filename) { - return path.join(this.vendorPath(), filename); + return path.join(this.vendorPath, filename); }, this)); }; - StitchCompiler.prototype.vendorPath = function() { - return this._vendor_path || (this._vendor_path = path.join(this.options.brunchPath, 'src/vendor')); - }; return StitchCompiler; })(); }).call(this); diff --git a/src/compilers/stitch.coffee b/src/compilers/stitch.coffee index f73163771..2ee6d2183 100644 --- a/src/compilers/stitch.coffee +++ b/src/compilers/stitch.coffee @@ -9,6 +9,10 @@ Compiler = require('./base').Compiler class exports.StitchCompiler extends Compiler + constructor: (options) -> + super options + @vendorPath = path.join(options.brunchPath, 'src/vendor') + filePattern: -> [/\.coffee$/, /src\/.*\.js$/, new RegExp("#{@options.templateExtension}$")] @@ -39,14 +43,11 @@ class exports.StitchCompiler extends Compiler # generate list of dependencies and preserve order of brunch libaries # like defined in options.dependencies collectDependencies: -> - filenames = fs.readdirSync @vendorPath() - filenames = helpers.filterFiles filenames, @vendorPath() + filenames = fs.readdirSync @vendorPath + filenames = helpers.filterFiles filenames, @vendorPath args = @options.dependencies.slice() args.unshift filenames additionalLibaries = _.without.apply @, args dependencies = @options.dependencies.concat additionalLibaries - _.map dependencies, (filename) => path.join(@vendorPath(), filename) - - vendorPath: -> - @_vendor_path ||= path.join(@options.brunchPath, 'src/vendor') + _.map dependencies, (filename) => path.join(@vendorPath, filename) diff --git a/test/collectDependencies.coffee b/test/collectDependencies.coffee index 2c7b7fdf2..2acac3bad 100644 --- a/test/collectDependencies.coffee +++ b/test/collectDependencies.coffee @@ -39,7 +39,7 @@ module.exports = testCase( ] compiler = new StitchCompiler options - compiler._vendor_path = 'test/fixtures/alternate_vendor' + compiler.vendorPath = 'test/fixtures/alternate_vendor' dependencyPaths = compiler.collectDependencies() test.deepEqual dependencyPaths, [