Skip to content

Commit

Permalink
moved generating vendorPath to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolaus Graf committed May 18, 2011
1 parent 634c125 commit c3e980d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
14 changes: 6 additions & 8 deletions lib/compilers/stitch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions src/compilers/stitch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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}$")]

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion test/collectDependencies.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down

0 comments on commit c3e980d

Please sign in to comment.