fs-jetpack
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,1 +1,4 @@ | ||
# 1.2.0 (2017-08-10) | ||
- Added symlinks search option to `find()`. | ||
# 1.1.0 (2017-06-18) | ||
@@ -2,0 +5,0 @@ - Parameter `overwrite` of `copy()` method now supports functions, to allow you individually decide if each file overwrite should happen. |
@@ -17,2 +17,3 @@ 'use strict'; | ||
recursive: ['boolean'], | ||
symlinks: ['boolean'], | ||
}); | ||
@@ -33,2 +34,5 @@ }; | ||
} | ||
if (opts.symlinks === undefined) { | ||
opts.symlinks = false; | ||
} | ||
return opts; | ||
@@ -76,3 +80,4 @@ }; | ||
if ((item.type === 'file' && options.files === true) | ||
|| (item.type === 'dir' && options.directories === true)) { | ||
|| (item.type === 'dir' && options.directories === true) | ||
|| (item.type === 'symlink' && options.symlinks === true)) { | ||
foundInspectObjects.push(item); | ||
@@ -122,3 +127,4 @@ } | ||
if ((item.type === 'file' && options.files === true) | ||
|| (item.type === 'dir' && options.directories === true)) { | ||
|| (item.type === 'dir' && options.directories === true) | ||
|| (item.type === 'symlink' && options.symlinks === true)) { | ||
foundInspectObjects.push(item); | ||
@@ -125,0 +131,0 @@ } |
{ | ||
"name": "fs-jetpack", | ||
"description": "Better file system API", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Jakub Szwacz <jakub@szwacz.com>", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -253,2 +253,3 @@ 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. | ||
@@ -280,2 +281,5 @@ **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. | ||
@@ -282,0 +286,0 @@ const myStuffDir = jetpack.cwd('my-stuff'); |
@@ -268,2 +268,29 @@ 'use strict'; | ||
describe("doesn't look for symlinks by default", () => { | ||
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']); | ||
}; | ||
it('sync', () => { | ||
preparations(); | ||
expectations(jetpack.find({ matching: '*' })); | ||
}); | ||
it('async', (done) => { | ||
preparations(); | ||
jetpack.findAsync({ matching: '*' }) | ||
.then((found) => { | ||
expectations(found); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('can look for files and directories', () => { | ||
@@ -403,2 +430,29 @@ 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", () => { | ||
@@ -574,4 +628,13 @@ 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`); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
257932
7378
518