Permalink
Browse files

you can indeed log too much

  • Loading branch information...
1 parent fa60b39 commit 2bad3a5639e5691da69708c2cff0f2e31f19bbdb @dbashford committed Dec 20, 2012
Showing with 60 additions and 59 deletions.
  1. +1 −0 .gitignore
  2. +57 −57 lib/register.coffee
  3. +2 −2 package.json
View
@@ -0,0 +1 @@
+node_modules
View
@@ -24,7 +24,7 @@ module.exports = class RequireRegister
path.join @config.watch.sourceDir, @config.watch.javascriptDir
else
path.join @config.watch.compiledDir, @config.watch.javascriptDir
- logger.debug "Root Javascript directory set at [[ #{@rootJavaScriptDir} ]]"
+ #logger.debug "Root Javascript directory set at [[ #{@rootJavaScriptDir} ]]"
process: (fileName, source) ->
require = @_require(fileName)
@@ -51,7 +51,7 @@ module.exports = class RequireRegister
buildDone: (@startupComplete = true) ->
return if @startupAlreadyDone
- logger.debug "***Require registration has learned that startup has completed, verifying require registrations***"
+ #logger.debug "***Require registration has learned that startup has completed, verifying require registrations***"
@startupAlreadyDone = true
@_verifyAll()
@@ -65,7 +65,7 @@ module.exports = class RequireRegister
for base, deps of @tree
bases.push(base) if deps.indexOf(fileName) >= 0
- logger.debug "Dependency tree bases for file [[ #{fileName} ]] are: #{bases.join('\n')}"
+ #logger.debug "Dependency tree bases for file [[ #{fileName} ]] are: #{bases.join('\n')}"
bases
@@ -83,16 +83,16 @@ module.exports = class RequireRegister
_logger: (message, method = 'error') ->
if @verify
logger[method](message)
- else
- logger.debug message
+ #else
+ #logger.debug message
_require: (fileName) ->
(deps, callback, errback, optional) =>
[deps, config] = @_requireOverride(deps, callback, errback, optional)
- logger.debug "Inside require function call for [[ #{fileName} ]], file has depedencies of:\n#{deps}"
+ #logger.debug "Inside require function call for [[ #{fileName} ]], file has depedencies of:\n#{deps}"
if config or deps
- logger.debug "[[ #{fileName} ]] has require configuration inside of it:\n#{JSON.stringify(config, null, 2)}"
+ #logger.debug "[[ #{fileName} ]] has require configuration inside of it:\n#{JSON.stringify(config, null, 2)}"
@requireFiles.push fileName
if config
@_handleConfigPaths(fileName, config.map ? null, config.paths ? null)
@@ -102,7 +102,7 @@ module.exports = class RequireRegister
_define: (fileName) ->
(id, deps, funct) =>
deps = @_defineOverride(id, deps, funct)
- logger.debug "Inside define block for [[ #{fileName} ]], found dependencies:\n#{deps}"
+ #logger.debug "Inside define block for [[ #{fileName} ]], found dependencies:\n#{deps}"
@_handleDeps(fileName, deps)
# may not be necessary, but for future reference
@@ -119,15 +119,15 @@ module.exports = class RequireRegister
r.specified = ->
_deleteForFileName: (fileName, aliases) ->
- logger.debug "Deleting aliases for file name [[ #{fileName} ]]"
- logger.debug "Aliases before delete:\n#{JSON.stringify(aliases, null, 2)}\n"
+ #logger.debug "Deleting aliases for file name [[ #{fileName} ]]"
+ #logger.debug "Aliases before delete:\n#{JSON.stringify(aliases, null, 2)}\n"
delete aliases[fileName] if aliases[fileName]
for fileName, paths of aliases
for alias, aliasPath of paths
delete paths[alias] if aliasPath is fileName
- logger.debug "Aliases after delete:\n#{JSON.stringify(aliases, null, 2)}\n"
+ #logger.debug "Aliases after delete:\n#{JSON.stringify(aliases, null, 2)}\n"
_verifyAll: ->
@_verifyConfigForFile(file) for file in @requireFiles
@@ -143,10 +143,10 @@ module.exports = class RequireRegister
_verifyShims: (fileName, shims) ->
unless shims?
- return logger.debug "No shims"
+ return # logger.debug "No shims"
for name, config of shims
- logger.debug "Processing shim [[ #{name} ]] with config of [[ #{JSON.stringify(config)} ]]"
+ #logger.debug "Processing shim [[ #{name} ]] with config of [[ #{JSON.stringify(config)} ]]"
unless @_fileExists(@_resolvePath(fileName, name))[0]
alias = @_findAlias(name, @aliasFiles)
unless alias
@@ -155,52 +155,52 @@ module.exports = class RequireRegister
deps = if Array.isArray(config) then config else config.deps
if deps?
for dep in deps
- logger.debug "Resolving shim dependency [[ #{dep} ]]"
+ #logger.debug "Resolving shim dependency [[ #{dep} ]]"
unless @_fileExists(@_resolvePath(fileName, dep))[0]
alias = @_findAlias(dep, @aliasFiles)
unless alias
@_logger "Shim [[ #{name} ]] inside file [[ #{fileName} ]] refers to a dependency that cannot be found [[ #{dep} ]]."
- else
- logger.debug "No 'deps' found for shim"
+ # else
+ #logger.debug "No 'deps' found for shim"
_buildTree: ->
for f in @requireFiles
- logger.debug "Building tree for require file [[ #{f} ]]"
+ #logger.debug "Building tree for require file [[ #{f} ]]"
@tree[f] = []
@_addDepsToTree(f, f, f)
- logger.debug "Full tree for require file [[ #{f} ]] is:\n#{JSON.stringify(@tree[f], null, f)}"
+ #logger.debug "Full tree for require file [[ #{f} ]] is:\n#{JSON.stringify(@tree[f], null, f)}"
_addDepsToTree: (f, dep, origDep) ->
unless @depsRegistry[dep]?
- return logger.debug "Dependency registry has no depedencies for [[ #{dep} ]]"
+ return #logger.debug "Dependency registry has no depedencies for [[ #{dep} ]]"
for aDep in @depsRegistry[dep]
exists = @_fileExists(aDep)[0]
unless exists
- logger.debug "Cannot find dependency [[ #{aDep} ]] for file [[ #{dep} ]], checking aliases/paths/maps"
+ #logger.debug "Cannot find dependency [[ #{aDep} ]] for file [[ #{dep} ]], checking aliases/paths/maps"
aDep = @_findAlias(aDep, @aliasFiles)
unless aDep?
- return logger.debug "Cannot find dependency [[ #{aDep} ]] in aliases, is likely bad path"
+ return #logger.debug "Cannot find dependency [[ #{aDep} ]] in aliases, is likely bad path"
if aDep.indexOf('MAPPED!') >= 0
aDep = @_findMappedDependency(dep, aDep)
- logger.debug "Dependency found in mappings [[ #{aDep} ]]"
+ #logger.debug "Dependency found in mappings [[ #{aDep} ]]"
- logger.debug "Resolved depencency for file [[ #{dep} ]] to [[ #{aDep} ]]"
+ #logger.debug "Resolved depencency for file [[ #{dep} ]] to [[ #{aDep} ]]"
if @tree[f].indexOf(aDep) < 0
- logger.debug "Adding dependency [[ #{aDep} ]] to the tree"
+ #logger.debug "Adding dependency [[ #{aDep} ]] to the tree"
@tree[f].push(aDep)
- else
- logger.debug "Dependency [[ #{aDep} ]] already in the tree, skipping"
+ #else
+ #logger.debug "Dependency [[ #{aDep} ]] already in the tree, skipping"
if aDep isnt origDep
@_addDepsToTree(f, aDep, dep)
- else
- logger.debug "[[ #{aDep} ]] may introduce a circular dependency"
+ #else
+ #logger.debug "[[ #{aDep} ]] may introduce a circular dependency"
_handleConfigPaths: (fileName, maps, paths) ->
@@ -238,27 +238,27 @@ module.exports = class RequireRegister
@_verifyConfigMappings(fileName, maps)
_verifyConfigMappings: (fileName, maps) ->
- logger.debug "Verifying [[ #{fileName} ]] maps:\n#{JSON.stringify(maps, null, 2)}"
+ #logger.debug "Verifying [[ #{fileName} ]] maps:\n#{JSON.stringify(maps, null, 2)}"
# rewrite module paths to full paths
for module, mappings of maps
if module isnt '*'
fullDepPath = @_resolvePath(fileName, module)
[exists, fullDepPath] = @_fileExists fullDepPath
if exists
- logger.debug "Verified path for module [[ #{module} ]] at [[ #{fullDepPath} ]]"
+ #logger.debug "Verified path for module [[ #{module} ]] at [[ #{fullDepPath} ]]"
delete maps[module]
maps[fullDepPath] = mappings
else
@_logger "Mapping inside file [[ #{fileName} ]], refers to module that cannot be found [[ #{module} ]]."
continue
- else
- logger.debug "Not going to verify path for '*'"
+ #else
+ #logger.debug "Not going to verify path for '*'"
for module, mappings of maps
for alias, aliasPath of mappings
fullDepPath = @_resolvePath(fileName, aliasPath)
if fullDepPath.indexOf('http') is 0
- logger.debug "Web path [[ #{fullDepPath} ]] for alias [[ #{alias} ]]being accepted"
+ #logger.debug "Web path [[ #{fullDepPath} ]] for alias [[ #{alias} ]]being accepted"
@aliasFiles[fileName][alias] = "MAPPED!#{alias}"
continue
@@ -268,49 +268,49 @@ module.exports = class RequireRegister
if alias then exists = true
if exists
- logger.debug "Found mapped dependency [[ #{alias} ]] at [[ #{fullDepPath} ]]"
+ #logger.debug "Found mapped dependency [[ #{alias} ]] at [[ #{fullDepPath} ]]"
@aliasFiles[fileName][alias] = "MAPPED!#{alias}"
maps[module][alias] = fullDepPath
else
@_logger "Mapping inside file [[ #{fileName} ]], for module [[ #{module} ]] has path that cannot be found [[ #{aliasPath} ]]."
_verifyConfigPath: (fileName, alias, aliasPath) ->
- logger.debug "Verifying configPath in fileName [[ #{fileName} ]], path alias [[ #{alias} ]], with aliasPath(s) of [[ #{aliasPath} ]]"
+ #logger.debug "Verifying configPath in fileName [[ #{fileName} ]], path alias [[ #{alias} ]], with aliasPath(s) of [[ #{aliasPath} ]]"
if Array.isArray(aliasPath)
- logger.debug "Paths are in array"
+ #logger.debug "Paths are in array"
for aPath in aliasPath
@_verifyConfigPath(fileName, alias, aPath)
return
# mapped paths are ok
if aliasPath.indexOf("MAPPED") is 0
- return logger.debug "Is mapped path [[ #{aliasPath} ]]"
+ return #logger.debug "Is mapped path [[ #{aliasPath} ]]"
# as are web resources, CDN, etc
if aliasPath.indexOf('http') is 0
- logger.debug "Is web resource path [[ #{aliasPath} ]]"
+ #logger.debug "Is web resource path [[ #{aliasPath} ]]"
return @aliasFiles[fileName][alias] = aliasPath
fullDepPath = @_resolvePath(fileName, aliasPath)
[exists, fullDepPath] = @_fileExists fullDepPath
if exists
if fs.statSync(fullDepPath).isDirectory()
- logger.debug "Path found at [[ #{fullDepPath}]], is a directory, adding to list of alias directories"
+ #logger.debug "Path found at [[ #{fullDepPath}]], is a directory, adding to list of alias directories"
@aliasDirectories[fileName][alias] = fullDepPath
else
- logger.debug "Path found at [[ #{fullDepPath}]], is a file, adding to list of alias files"
+ #logger.debug "Path found at [[ #{fullDepPath}]], is a file, adding to list of alias files"
@aliasFiles[fileName][alias] = fullDepPath
else
pathAsDirectory = fullDepPath.replace(/.js$/, '')
[pathAsDirExists, pathAsDirectory] = @_fileExists pathAsDirectory
if pathAsDirExists
- logger.debug "Path exists as directory, [[ #{pathAsDirectory} ]], adding to list of alias directories"
+ #logger.debug "Path exists as directory, [[ #{pathAsDirectory} ]], adding to list of alias directories"
@aliasDirectories[fileName] ?= {}
@aliasDirectories[fileName][alias] = pathAsDirectory
else
@_logger "Dependency [[ #{aliasPath} ]] for path alias [[ #{alias} ]], inside file [[ #{fileName} ]], cannot be found."
- logger.debug "Used this as full dependency path [[ #{fullDepPath} ]]"
+ #logger.debug "Used this as full dependency path [[ #{fullDepPath} ]]"
_verifyFileDeps: (fileName, deps) ->
@depsRegistry[fileName] = []
@@ -320,28 +320,28 @@ module.exports = class RequireRegister
_verifyDep: (fileName, dep) ->
# require, module = valid dependencies passed by require
if dep is 'require' or dep is 'module' or dep is 'exports'
- return logger.debug "Encountered keyword-esque dependency [[ #{dep} ]], ignoring."
+ return #logger.debug "Encountered keyword-esque dependency [[ #{dep} ]], ignoring."
# as are web resources, CDN, etc
if dep.indexOf('http') is 0
- logger.debug "Is web resource dependency [[ #{dep} ]], no further checking required"
+ #logger.debug "Is web resource dependency [[ #{dep} ]], no further checking required"
return @_registerDependency(fileName, dep)
# handle plugins
if dep.indexOf('!') >= 0
[plugin, dep] = dep.split('!')
- logger.debug "Is plugin dependency, going to verify plugin path [[ #{plugin}]]"
+ #logger.debug "Is plugin dependency, going to verify plugin path [[ #{plugin}]]"
@_verifyDep(fileName, plugin)
if dep?.length is 0
- return logger.debug "Plugin does not also have dependency"
+ return #logger.debug "Plugin does not also have dependency"
- logger.debug "Also going to verify plugin dependency [[ #{dep} ]]"
+ #logger.debug "Also going to verify plugin dependency [[ #{dep} ]]"
plugin = true
# resolve path, if mapped, find already calculated map path
fullDepPath = if dep.indexOf('MAPPED') is 0
- logger.debug "Is mapped dependency, looking in mappings..."
+ #logger.debug "Is mapped dependency, looking in mappings..."
@_findMappedDependency(fileName, dep)
else
@_resolvePath(fileName, dep, plugin)
@@ -351,13 +351,13 @@ module.exports = class RequireRegister
# file exists, register it
@_registerDependency(fileName, fullDepPath)
else
- logger.debug "Cannot find dependency [[ #{fullDepPath} ]], looking in paths..."
+ #logger.debug "Cannot find dependency [[ #{fullDepPath} ]], looking in paths..."
alias = @_findAlias(dep, @aliasFiles)
if alias
# file does not exist, but is aliased, register the alias
@_registerDependency(fileName, dep)
else
- logger.debug "Cannot find dependency as path alias..."
+ #logger.debug "Cannot find dependency as path alias..."
pathWithDirReplaced = @_findPathWhenAliasDiectory(dep)
[pathExists, pathAsDirReplaced] = @_fileExists pathWithDirReplaced if pathWithDirReplaced?
@@ -366,7 +366,7 @@ module.exports = class RequireRegister
@_registerDependency(fileName, pathWithDirReplaced)
else
@_logger "Dependency [[ #{dep} ]], inside file [[ #{fileName} ]], cannot be found."
- logger.debug "Used this as full dependency path [[ #{fullDepPath} ]]"
+ #logger.debug "Used this as full dependency path [[ #{fullDepPath} ]]"
@_registerDependency(fileName, dep)
# much sadness, cannot find the dependency
@@ -382,7 +382,7 @@ module.exports = class RequireRegister
@_logger "Mimosa has a bug! Ack! Cannot find mapping and it really should have."
_registerDependency: (fileName, dependency) ->
- logger.debug "Found dependency [[ #{dependency} ]] for file name [[ #{fileName} ]], registering it!"
+ #logger.debug "Found dependency [[ #{dependency} ]] for file name [[ #{fileName} ]], registering it!"
@depsRegistry[fileName].push(dependency)
if @_isCircular(fileName, dependency)
@_logger "A circular dependency exists between [[ #{fileName} ]] and [[ #{dependency} ]]", 'warn'
@@ -395,7 +395,7 @@ module.exports = class RequireRegister
_findAlias: (dep, aliases) ->
for fileName, paths of aliases
if paths[dep]?
- logger.debug "Found alias [[ #{paths[dep]} ]] in file name [[ #{fileName} ]] for dependency [[ #{dep} ]]"
+ #logger.debug "Found alias [[ #{paths[dep]} ]] in file name [[ #{fileName} ]] for dependency [[ #{dep} ]]"
return paths[dep]
_resolvePath: (fileName, dep, plugin = false) ->
@@ -411,7 +411,7 @@ module.exports = class RequireRegister
path.join @rootJavaScriptDir, dep
if fullPath.match(/\.\w+$/) and plugin
- logger.debug "Encountered plugin file with extension, letting that pass as is [[ #{fullPath} ]]"
+ #logger.debug "Encountered plugin file with extension, letting that pass as is [[ #{fullPath} ]]"
fullPath
else
"#{fullPath}.js"
@@ -420,7 +420,7 @@ module.exports = class RequireRegister
pathPieces = dep.split('/')
alias = @_findAlias(pathPieces[0], @aliasDirectories)
if alias
- logger.debug "Found alias as directory [[ #{alias} ]]"
+ #logger.debug "Found alias as directory [[ #{alias} ]]"
pathPieces[0] = alias
fullPath = pathPieces.join(path.sep)
"#{path.normalize(fullPath)}.js"
@@ -455,7 +455,7 @@ module.exports = class RequireRegister
deps = []
if !Array.isArray(deps)
- logger.warn "Not validating dependencies [[ #{deps} ]]. 'require' dependencies not set correctly. Dependencies should be an array."
+ #logger.warn "Not validating dependencies [[ #{deps} ]]. 'require' dependencies not set correctly. Dependencies should be an array."
deps = []
[deps, config]
@@ -466,7 +466,7 @@ module.exports = class RequireRegister
# templates is fine, will never be written, doesn't actually exist unless it is written
return [true, filePath] if filePath is path.join(@rootJavaScriptDir, "templates.js")
- logger.debug "Is virgin, need to try a bit harder to find file in source directories using extensions [[ #{@config.extensions.javascript} ]]"
+ #logger.debug "Is virgin, need to try a bit harder to find file in source directories using extensions [[ #{@config.extensions.javascript} ]]"
for extension in @config.extensions.javascript
newExtensionfilePath = filePath.replace(/\.[^.]+$/, ".#{extension}")
return [true, newExtensionfilePath] if fs.existsSync newExtensionfilePath
View
@@ -1,7 +1,7 @@
{
"name": "mimosa-require",
"preferGlobal": "false",
- "version": "0.5.4",
+ "version": "0.5.5",
"homepage": "http://www.mimosajs.com",
"author": "David Bashford",
"description": "AMD/RequireJS module for Mimosa browser development workflow tool",
@@ -30,7 +30,7 @@
],
"dependencies": {
"requirejs": "2.1.2",
- "lodash": "0.9.1",
+ "lodash": "1.0.0-rc.3",
"logmimosa": "0.2.1",
"uglify-js": "1.3.4",
"wrench": "1.4.4"

0 comments on commit 2bad3a5

Please sign in to comment.