Skip to content
Browse files

adding readme for file

  • Loading branch information...
1 parent 6d0fdae commit 4f43b5bf9e82ac8baacc02f35d31f8860dd1fd21 @aconbere aconbere committed
Showing with 46 additions and 3 deletions.
  1. +43 −0 file/README.md
  2. +3 −3 file/lib/main.js
View
43 file/README.md
@@ -0,0 +1,43 @@
+# File - Common higher level file and path operations
+
+## Install
+
+<pre>
+ npm install file
+</pre>
+
+## API
+
+### file.walk(start, callback)
+
+Navigates a file tree, calling callback for each directory, passing in (null, dirPath, dirs, files).
+
+
+### file.walkSync(start, callback)
+
+Like file.walk but synchronous.
+
+
+### file.mkdirs(path, 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)
+
+Like file.mkdirs but synchronous.
+
+
+### file.path.abspath(path)
+
+Expands ".", "..", "~" and non root paths to their full absolute path. Relative paths default to being children of the current working directory.
+
+
+### file.path.relpath(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"
View
6 file/lib/main.js
@@ -86,10 +86,10 @@ exports.walk = function (start, callback) {
return acc;
}, {"names": [], "dirs": []});
- callback(start, coll.dirs, coll.names);
+ return callback(null, start, coll.dirs, coll.names);
});
} else {
- return null;
+ return callback(new Error("path: " + start + " is not a directory"));
}
});
};
@@ -120,7 +120,7 @@ exports.walkSync = function (start, callback) {
});
} else {
- return null;
+ throw new Error("path: " + start + " is not a directory");
}
};

0 comments on commit 4f43b5b

Please sign in to comment.
Something went wrong with that request. Please try again.