fs-jetpack
Advanced tools
Comparing version 1.3.1 to 2.0.0
@@ -0,1 +1,4 @@ | ||
# 2.0.0 (2018-07-10) | ||
- **(breaking change)** removed `symlinks` config option of `find()` method. Now `find()` always follows symlinks. | ||
# 1.3.1 (2018-07-09) | ||
@@ -2,0 +5,0 @@ - Fixed bug in `existsAsync()`. |
@@ -16,4 +16,3 @@ "use strict"; | ||
directories: ["boolean"], | ||
recursive: ["boolean"], | ||
symlinks: ["boolean"] | ||
recursive: ["boolean"] | ||
}); | ||
@@ -34,5 +33,2 @@ }; | ||
} | ||
if (opts.symlinks === undefined) { | ||
opts.symlinks = false; | ||
} | ||
return opts; | ||
@@ -79,3 +75,4 @@ }; | ||
inspectOptions: { | ||
absolutePath: true | ||
absolutePath: true, | ||
symlinks: "follow" | ||
} | ||
@@ -87,4 +84,3 @@ }, | ||
(item.type === "file" && options.files === true) || | ||
(item.type === "dir" && options.directories === true) || | ||
(item.type === "symlink" && options.symlinks === true) | ||
(item.type === "dir" && options.directories === true) | ||
) { | ||
@@ -101,3 +97,3 @@ foundInspectObjects.push(item); | ||
const findSyncInit = (path, options) => { | ||
const entryPointInspect = inspect.sync(path); | ||
const entryPointInspect = inspect.sync(path, { symlinks: "follow" }); | ||
if (entryPointInspect === undefined) { | ||
@@ -130,3 +126,4 @@ throw generatePathDoesntExistError(path); | ||
inspectOptions: { | ||
absolutePath: true | ||
absolutePath: true, | ||
symlinks: "follow" | ||
} | ||
@@ -140,4 +137,3 @@ }) | ||
(item.type === "file" && options.files === true) || | ||
(item.type === "dir" && options.directories === true) || | ||
(item.type === "symlink" && options.symlinks === true) | ||
(item.type === "dir" && options.directories === true) | ||
) { | ||
@@ -156,3 +152,3 @@ foundInspectObjects.push(item); | ||
const findAsyncInit = (path, options) => { | ||
return inspect.async(path).then(entryPointInspect => { | ||
return inspect.async(path, { symlinks: "follow" }).then(entryPointInspect => { | ||
if (entryPointInspect === undefined) { | ||
@@ -159,0 +155,0 @@ throw generatePathDoesntExistError(path); |
{ | ||
"name": "fs-jetpack", | ||
"description": "Better file system API", | ||
"version": "1.3.1", | ||
"version": "2.0.0", | ||
"author": "Jakub Szwacz <jakub@szwacz.com>", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -269,3 +269,2 @@ fs-jetpack [![Build Status](https://travis-ci.org/szwacz/fs-jetpack.svg?branch=master)](https://travis-ci.org/szwacz/fs-jetpack) [![Build status](https://ci.appveyor.com/api/projects/status/er206e91fpuuqf58?svg=true)](https://ci.appveyor.com/project/szwacz/fs-jetpack) [![codecov](https://codecov.io/gh/szwacz/fs-jetpack/branch/master/graph/badge.svg)](https://codecov.io/gh/szwacz/fs-jetpack) | ||
* `recursive` (default `true`) whether the whole directory tree should be searched recursively, or only one-level of given directory (excluding it's subdirectories). | ||
* `symlinks` (default `false`) whether or not should report symlinks found. | ||
@@ -297,5 +296,2 @@ **returns:** | ||
// finds all dirs (including symlinked dirs) beginning with `plugin-*` in `node_modules` | ||
jetpack.find('node_modules', { matching: 'plugin-*', recursive: false, files: false, directories: true, symlinks: true }); | ||
// Path parameter might be omitted and CWD is used as path in that case. | ||
@@ -302,0 +298,0 @@ const myStuffDir = jetpack.cwd('my-stuff'); |
@@ -265,12 +265,12 @@ "use strict"; | ||
describe("doesn't look for symlinks by default", () => { | ||
describe("treats symlinks like real files", () => { | ||
const preparations = () => { | ||
fse.mkdirsSync("dir"); | ||
fse.outputFileSync("file", "abc"); | ||
fse.mkdirsSync("dir"); | ||
jetpack.symlink("dir", "symdir"); | ||
jetpack.symlink("file", "symfile"); | ||
jetpack.symlink("dir", "symdir"); | ||
}; | ||
const expectations = found => { | ||
expect(found).to.eql(["file"]); | ||
expect(found).to.eql(["file", "symfile"]); | ||
}; | ||
@@ -292,2 +292,30 @@ | ||
describe("follows to symlinked directories", () => { | ||
const preparations = () => { | ||
fse.outputFileSync("dir1/dir2/file.txt", "abc"); | ||
jetpack.symlink("../dir1", "foo/symlink_to_dir1"); | ||
expect(jetpack.read("foo/symlink_to_dir1/dir2/file.txt")).to.eql("abc"); | ||
}; | ||
const expectations = found => { | ||
const normalizedPaths = helper.osSep([ | ||
"foo/symlink_to_dir1/dir2/file.txt" | ||
]); | ||
expect(found).to.eql(normalizedPaths); | ||
}; | ||
it("sync", () => { | ||
preparations(); | ||
expectations(jetpack.find("foo", { matching: "file*" })); | ||
}); | ||
it("async", done => { | ||
preparations(); | ||
jetpack.findAsync("foo", { matching: "file*" }).then(found => { | ||
expectations(found); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("can look for files and directories", () => { | ||
@@ -439,28 +467,2 @@ const preparations = () => { | ||
describe("can look for symlinks", () => { | ||
const preparations = () => { | ||
fse.outputFileSync("file", "abc"); | ||
fse.mkdirsSync("dir"); | ||
jetpack.symlink("file", "symfile"); | ||
jetpack.symlink("dir", "symdir"); | ||
}; | ||
const expectations = found => { | ||
expect(found).to.eql(["file", "symdir", "symfile"]); | ||
}; | ||
it("sync", () => { | ||
preparations(); | ||
expectations(jetpack.find({ matching: "*", symlinks: true })); | ||
}); | ||
it("async", done => { | ||
preparations(); | ||
jetpack.findAsync({ matching: "*", symlinks: true }).then(found => { | ||
expectations(found); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe("throws if path doesn't exist", () => { | ||
@@ -657,17 +659,4 @@ const expectations = err => { | ||
}); | ||
describe('"symlinks" argument', () => { | ||
tests.forEach(test => { | ||
it(test.type, () => { | ||
expect(() => { | ||
test.method("abc", { symlinks: 1 }); | ||
}).to.throw( | ||
`Argument "options.symlinks" passed to ${ | ||
test.methodName | ||
}([path], options) must be a boolean. Received number` | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
264171
7747
530