Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Fix code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed May 11, 2012
1 parent 642e6e6 commit 90efff5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 3 additions & 7 deletions src/fs_utils/generated_file.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ module.exports = class GeneratedFile
files[paths.indexOf file]
sortedPaths = sourceFiles.map((file) -> file.path).join(', ')
logger.debug "Joining files '#{sortedPaths}' to '#{@path}'"
data = ''
joinFiles = (data) ->
data += sourceFiles.map((file) -> file.cache.data).join('')
callback null, data
joined = sourceFiles.map((file) -> file.cache.data).join('')
if @type is 'javascript'
getRequireDefinition (error, requireDefinition) =>
data += requireDefinition
joinFiles data
callback null, requireDefinition + joined
else
joinFiles data
callback null, joined

# Private: minify data.
#
Expand Down
12 changes: 7 additions & 5 deletions src/fs_utils/source_file.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ module.exports = class SourceFile
@path, @isHelper, @isVendor
}
@type = @compiler.type
@cache = Object.seal({data: '', dependencies: []})
@compilerName = @compiler.constructor.name
if isHelper
fileName = "brunch_#{@compilerName}_#{sysPath.basename @path}"
@realPath = @path
@path = sysPath.join 'vendor', 'scripts', fileName
@cache = Object.seal({data: '', dependencies: []})
Object.freeze(this)

_getDependencies: (data, path, callback) ->
fn = @compiler.getDependencies or (-> callback null, [])
fn data, path, callback

# Defines a requirejs module in scripts & templates.
# This allows brunch users to use `require 'module/name'` in browsers.
#
Expand Down Expand Up @@ -49,12 +53,10 @@ module.exports = class SourceFile
fs.readFile realPath, (error, buffer) =>
return callback "Read error: #{error}" if error?
fileContent = buffer.toString()
getDeps = @compiler.getDependencies or (data, path, callback) ->
callback null, []
@compiler.compile fileContent, @path, (error, result) =>
return callback "Compile error: #{error}" if error?
getDeps fileContent, @path, (error, dependencies) =>
@_getDependencies fileContent, @path, (error, dependencies) =>
return callback "GetDeps error: #{error}" if error?
@cache.dependencies = dependencies
@cache.data = @_wrap result if result?
callback error, @data
callback null, @cache.data

0 comments on commit 90efff5

Please sign in to comment.