Socket
Socket
Sign inDemoInstall

fs-jetpack

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 0.6.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

0.6.1 (2015-04-03)
-------------------
* Option `matching` in `copy()` and `find()` now accepts negation patterns (e.g. `!some/file.txt`).
0.6.0 (2015-03-30)

@@ -2,0 +6,0 @@ -------------------

@@ -17,3 +17,2 @@ // Matcher for glob patterns (e.g. *.txt, /a/b/**/z)

matchBase: true,
nonegate: false,
nocomment: true

@@ -23,12 +22,35 @@ });

return function (path) {
var doMatch = function (path) {
var mode = 'matching';
var weHaveMatch = false;
for (var i = 0; i < matchers.length; i += 1) {
if (matchers[i].match(path)) {
return true;
var ma = matchers[i];
if (ma.negate) {
mode = 'negation';
if (i === 0) {
// There are only negated patterns in the set,
// so make everything match by default and
// start to reject stuff.
weHaveMatch = true;
}
}
if (mode === 'negation' && weHaveMatch && !ma.match(path)) {
// One negation match is enought to know we can reject this one.
return false;
}
if (mode === 'matching' && !weHaveMatch) {
weHaveMatch = ma.match(path);
}
}
return false;
return weHaveMatch;
};
return doMatch;
};
module.exports.create = create;

2

package.json
{
"name": "fs-jetpack",
"description": "Better file system API",
"version": "0.6.0",
"version": "0.6.1",
"author": "Jakub Szwacz <jakub@szwacz.com>",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -323,3 +323,3 @@ "use strict";

it('can copy empty directory', function (done) {
it('can use negation patterns', function (done) {

@@ -329,2 +329,3 @@ var preparations = function () {

fse.mkdirsSync('dir/a/b');
fse.mkdirsSync('dir/a/c');
};

@@ -334,2 +335,3 @@

expect('copy/a/b').toBeDirectory();
expect('copy/a/c').not.toExist();
};

@@ -339,3 +341,3 @@

preparations();
jetpack.copy('dir', 'copy', { matching: 'b' });
jetpack.copy('dir', 'copy', { matching: ['b', '!c'] });
expectations();

@@ -345,3 +347,3 @@

preparations();
jetpack.copyAsync('dir', 'copy', { matching: 'b' })
jetpack.copyAsync('dir', 'copy', { matching: ['b', '!c'] })
.then(function () {

@@ -348,0 +350,0 @@ expectations();

@@ -177,2 +177,29 @@ "use strict";

it("deals with negated globs", function (done) {
var preparations = function () {
fse.outputFileSync('a/b/file.txt', '1');
fse.outputFileSync('a/b/file.md', '2');
fse.outputFileSync('a/b/c/file.txt', '3');
};
var expectations = function (found) {
var normalizedFound = helper.convertToUnixPathSeparators(found);
expect(normalizedFound).toEqual(['./b/c/file.txt', './b/file.txt']);
};
preparations();
// SYNC
var found = jetpack.find('a', { matching: ['file.*', '!*.md'] }, 'relativePath');
expectations(found);
// ASYNC
jetpack.findAsync('a', { matching: ['file.*', '!*.md'] }, 'relativePath')
.then(function (found) {
expectations(found);
done();
});
});
it("works even if provided path is a file", function (done) {

@@ -179,0 +206,0 @@

@@ -74,8 +74,4 @@ "use strict";

it("characters #! have NO special meaning", function () {
// these characters have meaning in .gitignore, but here should have not
var test = matcher.create(['!a']);
expect(test('/!a')).toBe(true);
test = matcher.create(['#a']);
it("comment character # havs no special meaning", function () {
var test = matcher.create(['#a']);
expect(test('/#a')).toBe(true);

@@ -86,2 +82,28 @@ });

describe("negation", function () {
it("selects everything except negated for one defined pattern", function () {
var test = matcher.create('!abc');
expect(test('/abc')).toBe(false);
expect(test('/xyz')).toBe(true);
});
it("selects everything except negated for multiple patterns", function () {
var test = matcher.create(['!abc', '!xyz']);
expect(test('/abc')).toBe(false);
expect(test('/xyz')).toBe(false);
expect(test('/whatever')).toBe(true);
});
it("filters previous match if negation is farther in order", function () {
var test = matcher.create(['abc', '123', '!/xyz/**', '!/789/**']);
expect(test('/abc')).toBe(true);
expect(test('/456/123')).toBe(true);
expect(test('/xyz/abc')).toBe(false);
expect(test('/789/123')).toBe(false);
expect(test('/whatever')).toBe(false);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc