Add fs.makeTree

This commit is contained in:
Corey Johnson
2012-07-03 14:46:45 -07:00
parent fc660c2790
commit 4cf4456635
2 changed files with 16 additions and 0 deletions

View File

@@ -54,6 +54,14 @@ describe "fs", ->
it "returns an empty string for paths without an extension", ->
expect(fs.extension("a/b.not-extension/a-dir")).toBe ''
describe "makeTree(path)", ->
beforeEach ->
fs.remove("/tmp/a") if fs.exists("/tmp/a")
it "creates all directories in path including any missing parent directories", ->
fs.makeTree("/tmp/a/b/c")
expect(fs.exists("/tmp/a/b/c")).toBeTruthy()
describe ".traverseTree(path, fn)", ->
fixturesDir = null

View File

@@ -93,6 +93,14 @@ module.exports =
makeDirectory: (path) ->
$native.makeDirectory(path)
# Creates the directory specified by "path" including any missing parent
# directories.
makeTree: (path) ->
return unless path
if not @exists(path)
@makeTree(@directory(path))
@makeDirectory(path)
traverseTree: (rootPath, fn) ->
recurse = null
prune = -> recurse = false