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

fs-jetpack - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

3

CHANGELOG.md

@@ -0,1 +1,4 @@

# 2.2.0 (2018-10-13)
- Added ignoreCase option to `find()` and `copy()` methods.
# 2.1.1 (2018-09-19)

@@ -2,0 +5,0 @@ - Rename file types.ts -> types.d.ts to fix https://github.com/szwacz/fs-jetpack/issues/72

@@ -20,3 +20,4 @@ "use strict";

overwrite: ["boolean", "function"],
matching: ["string", "array of string"]
matching: ["string", "array of string"],
ignoreCase: ["boolean"]
});

@@ -29,6 +30,14 @@ };

if (opts.ignoreCase === undefined) {
opts.ignoreCase = false;
}
parsedOptions.overwrite = opts.overwrite;
if (opts.matching) {
parsedOptions.allowedToCopy = matcher.create(from, opts.matching);
parsedOptions.allowedToCopy = matcher.create(
from,
opts.matching,
opts.ignoreCase
);
} else {

@@ -35,0 +44,0 @@ parsedOptions.allowedToCopy = () => {

@@ -16,3 +16,4 @@ "use strict";

directories: ["boolean"],
recursive: ["boolean"]
recursive: ["boolean"],
ignoreCase: ["boolean"]
});

@@ -27,2 +28,5 @@ };

}
if (opts.ignoreCase === undefined) {
opts.ignoreCase = false;
}
if (opts.directories === undefined) {

@@ -63,3 +67,7 @@ opts.directories = false;

const foundInspectObjects = [];
const matchesAnyOfGlobs = matcher.create(path, options.matching);
const matchesAnyOfGlobs = matcher.create(
path,
options.matching,
options.ignoreCase
);

@@ -113,3 +121,7 @@ let maxLevelsDeep = Infinity;

const foundInspectObjects = [];
const matchesAnyOfGlobs = matcher.create(path, options.matching);
const matchesAnyOfGlobs = matcher.create(
path,
options.matching,
options.ignoreCase
);

@@ -116,0 +128,0 @@ let maxLevelsDeep = Infinity;

3

lib/utils/matcher.js

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

exports.create = (basePath, patterns) => {
exports.create = (basePath, patterns, ignoreCase) => {
let normalizedPatterns;

@@ -52,2 +52,3 @@

nocomment: true,
nocase: ignoreCase || false,
dot: true

@@ -54,0 +55,0 @@ });

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

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

@@ -107,2 +107,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)

* `matching` if defined will actually copy **only** items matching any of specified glob patterns and omit everything else ([all possible globs are described further in this readme](#matching-patterns)).
* `ignoreCase` (default `false`) whether or not case should be ignored when processing glob patterns passed through the `matching` option.

@@ -283,2 +284,3 @@ **returns:**

* `recursive` (default `true`) whether the whole directory tree should be searched recursively, or only one-level of given directory (excluding it's subdirectories).
* `ignoreCase` (`false` otherwise) whether or not case should be ignored when processing glob patterns passed through the `matching` option.

@@ -285,0 +287,0 @@ **returns:**

@@ -575,2 +575,36 @@ import * as fse from "fs-extra";

describe("if ignoreCase=true it ignores case in patterns", () => {
// This test actually tests nothing if performed on case-insensitive file system.
const preparations = () => {
fse.mkdirsSync("orig/FoO/BaR/x");
};
const expectations = () => {
path("copy/FoO/BaR/x").shouldBeDirectory();
};
it("sync", () => {
preparations();
jetpack.copy("orig", "copy", {
matching: ["foo/bar/x"],
ignoreCase: true
});
expectations();
});
it("async", done => {
preparations();
jetpack
.copyAsync("orig", "copy", {
matching: ["foo/bar/x"],
ignoreCase: true
})
.then(() => {
expectations();
done();
});
});
});
if (process.platform !== "win32") {

@@ -670,4 +704,17 @@ describe("copies also file permissions (unix only)", () => {

});
describe('"ignoreCase" argument', () => {
tests.forEach(test => {
it(test.type, () => {
expect(() => {
test.method("abc", "xyz", { ignoreCase: 1 });
}).to.throw(
`Argument "options.ignoreCase" passed to ${
test.methodName
}(from, to, [options]) must be a boolean. Received number`
);
});
});
});
});
});
});

@@ -582,2 +582,40 @@ import * as fse from "fs-extra";

describe("if ignoreCase=true it ignores case in patterns", () => {
const preparations = () => {
fse.outputFileSync("FOO/BAR", "a");
};
const expectations = (found: string[]) => {
const paths = ["FOO", "FOO/BAR"];
const normalizedPaths = helper.osSep(paths);
expect(found).to.eql(normalizedPaths);
};
it("sync", () => {
preparations();
expectations(
jetpack.find({
matching: ["foo", "bar"],
directories: true,
ignoreCase: true
})
);
});
it("async", done => {
preparations();
jetpack
.findAsync({
matching: ["foo", "bar"],
directories: true,
ignoreCase: true
})
.then(found => {
expectations(found);
done();
})
.catch(done);
});
});
describe("input validation", () => {

@@ -660,4 +698,17 @@ const tests = [

});
describe('"ignoreCase" argument', () => {
tests.forEach(test => {
it(test.type, () => {
expect(() => {
test.method("abc", { ignoreCase: 1 });
}).to.throw(
`Argument "options.ignoreCase" passed to ${
test.methodName
}([path], options) must be a boolean. Received number`
);
});
});
});
});
});
});

@@ -19,2 +19,3 @@ /// <reference types="node" />

matching?: string | string[];
ignoreCase?: boolean;
};

@@ -40,2 +41,3 @@

recursive?: boolean;
ignoreCase?: boolean;
};

@@ -42,0 +44,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc