fs-jetpack
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -9,2 +9,3 @@ "use strict"; | ||
var copy = require('./copy'); | ||
var exists = require('./exists'); | ||
var read = require('./read'); | ||
@@ -15,7 +16,7 @@ var remove = require('./remove'); | ||
function jetpackContext(cwdPath) { | ||
function getCwdPath() { | ||
return cwdPath || process.cwd(); | ||
} | ||
function cwd(newCwdPath) { | ||
@@ -26,3 +27,3 @@ // return current CWD if no parameter... | ||
} | ||
// ...create new CWD context otherwise | ||
@@ -36,3 +37,3 @@ if (typeof newCwdPath === 'string') { | ||
} | ||
function path() { | ||
@@ -45,9 +46,9 @@ var path = getCwdPath(); | ||
} | ||
// API | ||
return { | ||
cwd: cwd, | ||
path: path, | ||
copy: function (from, to, options) { | ||
@@ -70,3 +71,3 @@ var normalizedFromPath = pathUtil.resolve(getCwdPath(), from); | ||
}, | ||
dir: function (path, criteria) { | ||
@@ -94,3 +95,10 @@ var normalizedPath = pathUtil.resolve(getCwdPath(), path); | ||
}, | ||
exists: function (path) { | ||
return exists.sync(pathUtil.resolve(getCwdPath(), path)); | ||
}, | ||
existsAsync: function (path) { | ||
return exists.async(pathUtil.resolve(getCwdPath(), path)); | ||
}, | ||
file: function (path, criteria) { | ||
@@ -109,3 +117,3 @@ file.sync(pathUtil.resolve(getCwdPath(), path), criteria); | ||
}, | ||
read: function (path, mode) { | ||
@@ -119,3 +127,3 @@ var normalizedPath = pathUtil.resolve(getCwdPath(), path); | ||
}, | ||
write: function (path, content) { | ||
@@ -127,3 +135,3 @@ return this.file(path, { content: content }); | ||
}, | ||
remove: function (path, options) { | ||
@@ -144,3 +152,3 @@ var normalizedPath = pathUtil.resolve(getCwdPath(), path); | ||
}, | ||
list: function (path, options) { | ||
@@ -157,2 +165,2 @@ var normalizedPath = pathUtil.resolve(getCwdPath(), path); | ||
module.exports = jetpackContext; | ||
module.exports = jetpackContext; |
{ | ||
"name": "fs-jetpack", | ||
"description": "Jetpack for 'fs' library", | ||
"version": "0.2.0", | ||
"description": "Higher level API for 'fs' library", | ||
"version": "0.3.0", | ||
"author": "Jakub Szwacz <jakub@szwacz.com>", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -28,2 +28,4 @@ #fs-jetpack | ||
* <a href="#dirasyncpath-criteria">dirAsync(path, [criteria])</a> | ||
* <a href="#existspath">exists(path)</a> | ||
* <a href="#existsasyncpath">existsAsync(path)</a> | ||
* <a href="#filepath-criteria">file(path, [criteria])</a> | ||
@@ -144,2 +146,16 @@ * <a href="#fileasyncpath-criteria">fileAsync(path, [criteria])</a> | ||
###exists(path) | ||
Checks whether something exists on given `path`. This method returns values more specyfic than `true/false` to protect from errors like "I was expecting directory, but it was a file". | ||
**returns:** | ||
* `false` if path doesn't exist. | ||
* `"dir"` if path is a directory. | ||
* `"file"` if path is a file. | ||
* `"other"` if path exists, but is of different "type". | ||
###existsAsync(path) | ||
Asynchronous equivalent of `exists()` method. The only difference is that it returns promise. | ||
###file(path, [criteria]) | ||
@@ -146,0 +162,0 @@ Ensures that file meets given criteria. If any criterium is not met it will be after this call. |
56211
15
1118
374
7