1 | # File - Common higher level file and path operations
|
2 |
|
3 | ## Install
|
4 |
|
5 | <pre>
|
6 | npm install file
|
7 | </pre>
|
8 |
|
9 | <pre>
|
10 | var file = require("file");
|
11 | </pre>
|
12 |
|
13 | ## API
|
14 |
|
15 | ### file.walk(start, callback)
|
16 |
|
17 | Navigates a file tree, calling callback for each directory, passing in (null, dirPath, dirs, files).
|
18 |
|
19 |
|
20 | ### file.walkSync(start, callback)
|
21 |
|
22 | Like file.walk but synchronous.
|
23 |
|
24 |
|
25 | ### file.mkdirs(path, mode, callback)
|
26 |
|
27 | 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".
|
28 |
|
29 |
|
30 | ### file.mkdirsSync(path, mode)
|
31 |
|
32 | Like file.mkdirs but synchronous.
|
33 |
|
34 |
|
35 | ### file.path.abspath(path)
|
36 |
|
37 | Expands ".", "..", "~" and non root paths to their full absolute path. Relative paths default to being children of the current working directory.
|
38 |
|
39 |
|
40 | ### file.path.relpath(root, fullPath)
|
41 |
|
42 | Given a root path, and a fullPath attempts to diff between the two to give us an acurate path relative to root.
|
43 |
|
44 |
|
45 | ### file.path.join(head, tail)
|
46 |
|
47 | 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"
|