Higher level path and file manipulation functions.

npm install file
1 058 downloads in the last day
4 498 downloads in the last week
22 449 downloads in the last month

File - Common higher level file and path operations


  npm install file
  var file = require("file");


file.walk(start, callback)

Navigates a file tree, calling callback for each directory, passing in (null, dirPath, dirs, files).

file.walkSync(start, callback)

Synchronus version of file.walk, calling callback for each directory, passing in (dirPath, dirs, files).

file.mkdirs(path, mode, callback)

Makes all the directories in a path. (analgous to mkdir -P) For example given a path like "test/this/path" in an empty directory, mkdirs would make the directories "test", "this" and "path".

file.mkdirsSync(path, mode)

Like file.mkdirs but synchronous.


Expands ".", "..", "~" and non root paths to their full absolute path. Relative paths default to being children of the current working directory.

file.path.relativePath(root, fullPath)

Given a root path, and a fullPath attempts to diff between the two to give us an acurate path relative to root.

file.path.join(head, tail)

Just like path.join but haves a little more sanely when give a head equal to "". file.path.join("", "tail") returns "tail", path.join("", "tail") returns "/tail"

npm loves you