Skip to content

Commit

Permalink
Fix flatten function (bug introduce by coffee migration)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Oct 6, 2011
1 parent 9029c36 commit b2cd042
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions lib/utils.coffee
@@ -1,18 +1,25 @@

module.exports.pad = (n, size) ->
n = n.toString()
pad = ''
size = size - n.length
for i in [0 .. size]
pad += ' '
n + pad
path = require 'path'

module.exports.flatten = (arr, ret) ->
ret ?= []
len = arr.length
for i in [0 .. len]
if Array.isArray arr[i]
exports.flatten arr[i], ret
else
ret.push arr[i]
ret
module.exports =
pad: (n, size) ->
n = n.toString()
pad = ''
size = size - n.length
for i in [0 .. size]
pad += ' '
n + pad
flatten: (arr, ret) ->
ret ?= []
for i in [0 ... arr.length]
if Array.isArray arr[i]
@flatten arr[i], ret
else
ret.push arr[i]
ret
# Discovery the project root directory or return null if undiscoverable
workspace: () ->
dirs = require('module')._nodeModulePaths process.cwd()
for dir in dirs
if path.existsSync(dir) || path.existsSync(path.normalize(dir + '/../package.json'))
return path.normalize dir + '/..'

0 comments on commit b2cd042

Please sign in to comment.