Ensuring node modules are up to date for running

This commit is contained in:
Drew Heavner
2021-03-18 14:18:40 +00:00
committed by GitHub
parent 0bff061163
commit edc6575646
311 changed files with 12398 additions and 3 deletions

21
node_modules/@nodelib/fs.walk/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Denis Malinochkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

215
node_modules/@nodelib/fs.walk/README.md generated vendored Normal file
View File

@@ -0,0 +1,215 @@
# @nodelib/fs.walk
> A library for efficiently walking a directory recursively.
## :bulb: Highlights
* :moneybag: Returns useful information: `name`, `path`, `dirent` and `stats` (optional).
* :rocket: On Node.js 10.10+ uses the mechanism without additional calls to determine the entry type for performance reasons. See [`old` and `modern` mode](https://github.com/nodelib/nodelib/blob/master/packages/fs/fs.scandir/README.md#old-and-modern-mode).
* :gear: Built-in directories/files and error filtering system.
* :link: Can safely work with broken symbolic links.
## Install
```console
npm install @nodelib/fs.walk
```
## Usage
```ts
import * as fsWalk from '@nodelib/fs.walk';
fsWalk.walk('path', (error, entries) => { /* … */ });
```
## API
### .walk(path, [optionsOrSettings], callback)
Reads the directory recursively and asynchronously. Requires a callback function.
> :book: If you want to use the Promise API, use `util.promisify`.
```ts
fsWalk.walk('path', (error, entries) => { /* … */ });
fsWalk.walk('path', {}, (error, entries) => { /* … */ });
fsWalk.walk('path', new fsWalk.Settings(), (error, entries) => { /* … */ });
```
### .walkStream(path, [optionsOrSettings])
Reads the directory recursively and asynchronously. [Readable Stream](https://nodejs.org/dist/latest-v12.x/docs/api/stream.html#stream_readable_streams) is used as a provider.
```ts
const stream = fsWalk.walkStream('path');
const stream = fsWalk.walkStream('path', {});
const stream = fsWalk.walkStream('path', new fsWalk.Settings());
```
### .walkSync(path, [optionsOrSettings])
Reads the directory recursively and synchronously. Returns an array of entries.
```ts
const entries = fsWalk.walkSync('path');
const entries = fsWalk.walkSync('path', {});
const entries = fsWalk.walkSync('path', new fsWalk.Settings());
```
#### path
* Required: `true`
* Type: `string | Buffer | URL`
A path to a file. If a URL is provided, it must use the `file:` protocol.
#### optionsOrSettings
* Required: `false`
* Type: `Options | Settings`
* Default: An instance of `Settings` class
An [`Options`](#options) object or an instance of [`Settings`](#settings) class.
> :book: When you pass a plain object, an instance of the `Settings` class will be created automatically. If you plan to call the method frequently, use a pre-created instance of the `Settings` class.
### Settings([options])
A class of full settings of the package.
```ts
const settings = new fsWalk.Settings({ followSymbolicLinks: true });
const entries = fsWalk.walkSync('path', settings);
```
## Entry
* `name` — The name of the entry (`unknown.txt`).
* `path` — The path of the entry relative to call directory (`root/unknown.txt`).
* `dirent` — An instance of [`fs.Dirent`](./src/types/index.ts) class.
* [`stats`] — An instance of `fs.Stats` class.
## Options
### basePath
* Type: `string`
* Default: `undefined`
By default, all paths are built relative to the root path. You can use this option to set custom root path.
In the example below we read the files from the `root` directory, but in the results the root path will be `custom`.
```ts
fsWalk.walkSync('root'); // → ['root/file.txt']
fsWalk.walkSync('root', { basePath: 'custom' }); // → ['custom/file.txt']
```
### concurrency
* Type: `number`
* Default: `Infinity`
The maximum number of concurrent calls to `fs.readdir`.
> :book: The higher the number, the higher performance and the load on the File System. If you want to read in quiet mode, set the value to `4 * os.cpus().length` (4 is default size of [thread pool work scheduling](http://docs.libuv.org/en/v1.x/threadpool.html#thread-pool-work-scheduling)).
### deepFilter
* Type: [`DeepFilterFunction`](./src/settings.ts)
* Default: `undefined`
A function that indicates whether the directory will be read deep or not.
```ts
// Skip all directories that starts with `node_modules`
const filter: DeepFilterFunction = (entry) => !entry.path.startsWith('node_modules');
```
### entryFilter
* Type: [`EntryFilterFunction`](./src/settings.ts)
* Default: `undefined`
A function that indicates whether the entry will be included to results or not.
```ts
// Exclude all `.js` files from results
const filter: EntryFilterFunction = (entry) => !entry.name.endsWith('.js');
```
### errorFilter
* Type: [`ErrorFilterFunction`](./src/settings.ts)
* Default: `undefined`
A function that allows you to skip errors that occur when reading directories.
For example, you can skip `ENOENT` errors if required:
```ts
// Skip all ENOENT errors
const filter: ErrorFilterFunction = (error) => error.code == 'ENOENT';
```
### stats
* Type: `boolean`
* Default: `false`
Adds an instance of `fs.Stats` class to the [`Entry`](#entry).
> :book: Always use `fs.readdir` with additional `fs.lstat/fs.stat` calls to determine the entry type.
### followSymbolicLinks
* Type: `boolean`
* Default: `false`
Follow symbolic links or not. Call `fs.stat` on symbolic link if `true`.
### `throwErrorOnBrokenSymbolicLink`
* Type: `boolean`
* Default: `true`
Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`.
### `pathSegmentSeparator`
* Type: `string`
* Default: `path.sep`
By default, this package uses the correct path separator for your OS (`\` on Windows, `/` on Unix-like systems). But you can set this option to any separator character(s) that you want to use instead.
### `fs`
* Type: `FileSystemAdapter`
* Default: A default FS methods
By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace any method with your own.
```ts
interface FileSystemAdapter {
lstat: typeof fs.lstat;
stat: typeof fs.stat;
lstatSync: typeof fs.lstatSync;
statSync: typeof fs.statSync;
readdir: typeof fs.readdir;
readdirSync: typeof fs.readdirSync;
}
const settings = new fsWalk.Settings({
fs: { lstat: fakeLstat }
});
```
## Changelog
See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelog for each release version.
## License
This software is released under the terms of the MIT license.

15
node_modules/@nodelib/fs.walk/out/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
/// <reference types="node" />
import { Readable } from 'stream';
import { Dirent, FileSystemAdapter } from '@nodelib/fs.scandir';
import { AsyncCallback } from './providers/async';
import Settings, { DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction, Options } from './settings';
import { Entry } from './types';
declare function walk(directory: string, callback: AsyncCallback): void;
declare function walk(directory: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
declare namespace walk {
function __promisify__(directory: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
}
declare function walkSync(directory: string, optionsOrSettings?: Options | Settings): Entry[];
declare function walkStream(directory: string, optionsOrSettings?: Options | Settings): Readable;
export { walk, walkSync, walkStream, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, Options, DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction };
//# sourceMappingURL=index.d.ts.map

1
node_modules/@nodelib/fs.walk/out/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAsB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGjE,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,iBAAS,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;AAChE,iBAAS,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAG,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;AAWvG,OAAO,WAAW,IAAI,CAAC;IACtB,SAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;CACpG;AAED,iBAAS,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,EAAE,CAKpF;AAED,iBAAS,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAKvF;AAUD,OAAO,EACN,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EAER,aAAa,EACb,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,OAAO,EACP,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,CAAC"}

33
node_modules/@nodelib/fs.walk/out/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0;
const async_1 = require("./providers/async");
const stream_1 = require("./providers/stream");
const sync_1 = require("./providers/sync");
const settings_1 = require("./settings");
exports.Settings = settings_1.default;
function walk(directory, optionsOrSettingsOrCallback, callback) {
if (typeof optionsOrSettingsOrCallback === 'function') {
return new async_1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
}
new async_1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
}
exports.walk = walk;
function walkSync(directory, optionsOrSettings) {
const settings = getSettings(optionsOrSettings);
const provider = new sync_1.default(directory, settings);
return provider.read();
}
exports.walkSync = walkSync;
function walkStream(directory, optionsOrSettings) {
const settings = getSettings(optionsOrSettings);
const provider = new stream_1.default(directory, settings);
return provider.read();
}
exports.walkStream = walkStream;
function getSettings(settingsOrOptions = {}) {
if (settingsOrOptions instanceof settings_1.default) {
return settingsOrOptions;
}
return new settings_1.default(settingsOrOptions);
}

2
node_modules/@nodelib/fs.walk/out/index.spec.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=index.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":""}

99
node_modules/@nodelib/fs.walk/out/index.spec.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const fs = require("fs");
const rimraf = require("rimraf");
const _1 = require(".");
const entryFilter = (entry) => !entry.dirent.isDirectory();
function streamToPromise(stream) {
const entries = [];
return new Promise((resolve, reject) => {
stream.on('data', (entry) => entries.push(entry));
stream.once('error', reject);
stream.once('end', () => resolve(entries));
});
}
describe('Package', () => {
before(() => {
rimraf.sync('fixtures');
fs.mkdirSync('fixtures');
fs.writeFileSync('fixtures/file.txt', '');
fs.mkdirSync('fixtures/nested');
fs.writeFileSync('fixtures/nested/file.txt', '');
});
after(() => {
rimraf.sync('fixtures');
});
describe('.walk', () => {
it('should throw an error for non-exist directory', (done) => {
_1.walk('non-exist-directory', (error, entries) => {
assert.strictEqual(error.code, 'ENOENT');
assert.strictEqual(entries, undefined);
done();
});
});
it('should work without options or settings', (done) => {
_1.walk('fixtures', (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 3);
done();
});
});
it('should work with options', (done) => {
_1.walk('fixtures', { entryFilter }, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
done();
});
});
it('should work with settings', (done) => {
const settings = new _1.Settings({ entryFilter });
_1.walk('fixtures', settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
done();
});
});
});
describe('.walkStream', () => {
it('should throw an error for non-exist directory', async () => {
const stream = _1.walkStream('non-exist-directory');
await assert.rejects(() => streamToPromise(stream), (error) => error.code === 'ENOENT');
});
it('should work without options or settings', async () => {
const stream = _1.walkStream('fixtures');
const actual = await streamToPromise(stream);
assert.strictEqual(actual.length, 3);
});
it('should work with options', async () => {
const stream = _1.walkStream('fixtures', { entryFilter });
const actual = await streamToPromise(stream);
assert.strictEqual(actual.length, 2);
});
it('should work with settings', async () => {
const settings = new _1.Settings({ entryFilter });
const stream = _1.walkStream('fixtures', settings);
const actual = await streamToPromise(stream);
assert.strictEqual(actual.length, 2);
});
});
describe('.walkSync', () => {
it('should throw an error for non-exist directory', () => {
const matcher = (error) => error.code === 'ENOENT';
assert.throws(() => _1.walkSync('non-exist-directory'), matcher);
});
it('should work without options or settings', () => {
const actual = _1.walkSync('fixtures');
assert.strictEqual(actual.length, 3);
});
it('should work with options', () => {
const actual = _1.walkSync('fixtures', { entryFilter });
assert.strictEqual(actual.length, 2);
});
it('should work with settings', () => {
const settings = new _1.Settings({ entryFilter });
const actual = _1.walkSync('fixtures', settings);
assert.strictEqual(actual.length, 2);
});
});
});

13
node_modules/@nodelib/fs.walk/out/providers/async.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import AsyncReader from '../readers/async';
import Settings from '../settings';
import { Entry, Errno } from '../types';
export declare type AsyncCallback = (err: Errno, entries: Entry[]) => void;
export default class AsyncProvider {
private readonly _root;
private readonly _settings;
protected readonly _reader: AsyncReader;
private readonly _storage;
constructor(_root: string, _settings: Settings);
read(callback: AsyncCallback): void;
}
//# sourceMappingURL=async.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/providers/async.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKxC,oBAAY,aAAa,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;AAEnE,MAAM,CAAC,OAAO,OAAO,aAAa;IAKrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAU,OAAO,CAAC,QAAQ,CAAC,SAAS;IAJtE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAA+C;IAEtF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAErB,KAAK,EAAE,MAAM,EAAmB,SAAS,EAAE,QAAQ;IAEzE,IAAI,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;CAe1C"}

30
node_modules/@nodelib/fs.walk/out/providers/async.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const async_1 = require("../readers/async");
class AsyncProvider {
constructor(_root, _settings) {
this._root = _root;
this._settings = _settings;
this._reader = new async_1.default(this._root, this._settings);
this._storage = new Set();
}
read(callback) {
this._reader.onError((error) => {
callFailureCallback(callback, error);
});
this._reader.onEntry((entry) => {
this._storage.add(entry);
});
this._reader.onEnd(() => {
callSuccessCallback(callback, [...this._storage]);
});
this._reader.read();
}
}
exports.default = AsyncProvider;
function callFailureCallback(callback, error) {
callback(error);
}
function callSuccessCallback(callback, entries) {
callback(null, entries);
}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=async.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.spec.d.ts","sourceRoot":"","sources":["../../src/providers/async.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const sinon = require("sinon");
const settings_1 = require("../settings");
const tests = require("../tests");
const async_1 = require("./async");
class TestProvider extends async_1.default {
constructor(_root, _settings = new settings_1.default()) {
super(_root, _settings);
this._reader = new tests.TestAsyncReader();
}
get reader() {
return this._reader;
}
}
describe('Providers → Async', () => {
describe('.read', () => {
it('should call reader function with correct set of arguments', () => {
const provider = new TestProvider('directory');
const fakeCallback = sinon.stub();
provider.read(fakeCallback);
assert.ok(provider.reader.read.called);
});
it('should call callback with error for failed launch', () => {
const provider = new TestProvider('directory');
const fakeCallback = sinon.stub();
provider.reader.onError.yields(tests.EPERM_ERRNO);
provider.read(fakeCallback);
assert.deepStrictEqual(fakeCallback.args, [[tests.EPERM_ERRNO]]);
});
it('should push entries to storage and call callback with array of entries', () => {
const provider = new TestProvider('directory');
const fakeEntry = tests.buildFakeFileEntry();
const fakeCallback = sinon.stub();
provider.reader.onEntry.yields(fakeEntry);
provider.reader.onEnd.yields();
provider.read(fakeCallback);
assert.deepStrictEqual(fakeCallback.args, [[null, [fakeEntry]]]);
});
});
});

View File

@@ -0,0 +1,5 @@
import AsyncProvider from './async';
import StreamProvider from './stream';
import SyncProvider from './sync';
export { AsyncProvider, StreamProvider, SyncProvider };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,SAAS,CAAC;AACpC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EACN,aAAa,EACb,cAAc,EACd,YAAY,EACZ,CAAC"}

9
node_modules/@nodelib/fs.walk/out/providers/index.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SyncProvider = exports.StreamProvider = exports.AsyncProvider = void 0;
const async_1 = require("./async");
exports.AsyncProvider = async_1.default;
const stream_1 = require("./stream");
exports.StreamProvider = stream_1.default;
const sync_1 = require("./sync");
exports.SyncProvider = sync_1.default;

View File

@@ -0,0 +1,13 @@
/// <reference types="node" />
import { Readable } from 'stream';
import AsyncReader from '../readers/async';
import Settings from '../settings';
export default class StreamProvider {
private readonly _root;
private readonly _settings;
protected readonly _reader: AsyncReader;
protected readonly _stream: Readable;
constructor(_root: string, _settings: Settings);
read(): Readable;
}
//# sourceMappingURL=stream.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/providers/stream.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,MAAM,CAAC,OAAO,OAAO,cAAc;IAYtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAU,OAAO,CAAC,QAAQ,CAAC,SAAS;IAXtE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAA+C;IACtF,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAQjC;gBAE0B,KAAK,EAAE,MAAM,EAAmB,SAAS,EAAE,QAAQ;IAEzE,IAAI,IAAI,QAAQ;CAiBvB"}

34
node_modules/@nodelib/fs.walk/out/providers/stream.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const stream_1 = require("stream");
const async_1 = require("../readers/async");
class StreamProvider {
constructor(_root, _settings) {
this._root = _root;
this._settings = _settings;
this._reader = new async_1.default(this._root, this._settings);
this._stream = new stream_1.Readable({
objectMode: true,
read: () => { },
destroy: () => {
if (!this._reader.isDestroyed) {
this._reader.destroy();
}
}
});
}
read() {
this._reader.onError((error) => {
this._stream.emit('error', error);
});
this._reader.onEntry((entry) => {
this._stream.push(entry);
});
this._reader.onEnd(() => {
this._stream.push(null);
});
this._reader.read();
return this._stream;
}
}
exports.default = StreamProvider;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=stream.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"stream.spec.d.ts","sourceRoot":"","sources":["../../src/providers/stream.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const stream_1 = require("stream");
const sinon = require("sinon");
const settings_1 = require("../settings");
const tests = require("../tests");
const stream_2 = require("./stream");
class TestProvider extends stream_2.default {
constructor(_root, _settings = new settings_1.default()) {
super(_root, _settings);
this._reader = new tests.TestAsyncReader();
this._stream.emit = sinon.stub();
this._stream.push = sinon.stub();
}
get reader() {
return this._reader;
}
get stream() {
return this._stream;
}
}
describe('Providers → Stream', () => {
describe('.read', () => {
it('should return stream', () => {
const provider = new TestProvider('directory');
const stream = provider.read();
assert.ok(stream instanceof stream_1.Readable);
});
it('should call reader function with correct set of arguments', () => {
const provider = new TestProvider('directory');
provider.read();
assert.ok(provider.reader.read.called);
});
it('should re-emit the "error" event from reader', () => {
const provider = new TestProvider('directory');
provider.reader.onError.yields(tests.EPERM_ERRNO);
provider.read();
assert.deepStrictEqual(provider.stream.emit.args, [['error', tests.EPERM_ERRNO]]);
});
it('should call the "push" method with entry value for the "entry" event from reader', () => {
const provider = new TestProvider('directory');
const fakeEntry = tests.buildFakeFileEntry();
provider.reader.onEntry.yields(fakeEntry);
provider.read();
assert.deepStrictEqual(provider.stream.push.args, [[fakeEntry]]);
});
it('should call the "push" method with "null" value for the "end" event from reader', () => {
const provider = new TestProvider('directory');
provider.reader.onEnd.yields();
provider.read();
assert.deepStrictEqual(provider.stream.push.args, [[null]]);
});
it('should do not destroy reader when it is already destroyed', () => {
const provider = new TestProvider('directory');
const stream = provider.read();
stream.destroy();
assert.ok(stream.destroyed);
assert.doesNotThrow(() => stream.destroy());
});
});
});

11
node_modules/@nodelib/fs.walk/out/providers/sync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import SyncReader from '../readers/sync';
import Settings from '../settings';
import { Entry } from '../types';
export default class SyncProvider {
private readonly _root;
private readonly _settings;
protected readonly _reader: SyncReader;
constructor(_root: string, _settings: Settings);
read(): Entry[];
}
//# sourceMappingURL=sync.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/providers/sync.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,OAAO,OAAO,YAAY;IAGpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAU,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAA8C;gBAEvD,KAAK,EAAE,MAAM,EAAmB,SAAS,EAAE,QAAQ;IAEzE,IAAI,IAAI,KAAK,EAAE;CAGtB"}

14
node_modules/@nodelib/fs.walk/out/providers/sync.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const sync_1 = require("../readers/sync");
class SyncProvider {
constructor(_root, _settings) {
this._root = _root;
this._settings = _settings;
this._reader = new sync_1.default(this._root, this._settings);
}
read() {
return this._reader.read();
}
}
exports.default = SyncProvider;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=sync.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sync.spec.d.ts","sourceRoot":"","sources":["../../src/providers/sync.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const settings_1 = require("../settings");
const tests = require("../tests");
const sync_1 = require("./sync");
class TestProvider extends sync_1.default {
constructor(_root, _settings = new settings_1.default()) {
super(_root, _settings);
this._reader = new tests.TestSyncReader();
}
get reader() {
return this._reader;
}
}
describe('Providers → Sync', () => {
describe('.read', () => {
it('should call reader function with correct set of arguments and got result', () => {
const provider = new TestProvider('directory');
const fakeEntry = tests.buildFakeFileEntry();
provider.reader.read.returns([fakeEntry]);
const actual = provider.read();
assert.deepStrictEqual(actual, [fakeEntry]);
assert.ok(provider.reader.read.called);
});
});
});

31
node_modules/@nodelib/fs.walk/out/readers/async.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/// <reference types="node" />
import { EventEmitter } from 'events';
import * as fsScandir from '@nodelib/fs.scandir';
import Settings from '../settings';
import { Entry, Errno } from '../types';
import Reader from './reader';
declare type EntryEventCallback = (entry: Entry) => void;
declare type ErrorEventCallback = (error: Errno) => void;
declare type EndEventCallback = () => void;
export default class AsyncReader extends Reader {
protected readonly _settings: Settings;
protected readonly _scandir: typeof fsScandir.scandir;
protected readonly _emitter: EventEmitter;
private readonly _queue;
private _isFatalError;
private _isDestroyed;
constructor(_root: string, _settings: Settings);
read(): EventEmitter;
get isDestroyed(): boolean;
destroy(): void;
onEntry(callback: EntryEventCallback): void;
onError(callback: ErrorEventCallback): void;
onEnd(callback: EndEventCallback): void;
private _pushToQueue;
private _worker;
private _handleError;
private _handleEntry;
private _emitEntry;
}
export {};
//# sourceMappingURL=async.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/readers/async.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAC;AAGjD,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAa,MAAM,UAAU,CAAC;AAEnD,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,aAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AACjD,aAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AACjD,aAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAEnC,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,MAAM;IAQnB,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ;IAPjE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,OAAO,CAAqB;IAC1E,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAsB;IAE/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2E;IAClG,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAkB;gBAE1B,KAAK,EAAE,MAAM,EAAqB,SAAS,EAAE,QAAQ;IAU1D,IAAI,IAAI,YAAY;IAW3B,IAAW,WAAW,IAAI,OAAO,CAEhC;IAEM,OAAO,IAAI,IAAI;IASf,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAI3C,OAAO,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAI3C,KAAK,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAI9C,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,OAAO;IAcf,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,UAAU;CAGlB"}

96
node_modules/@nodelib/fs.walk/out/readers/async.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const fsScandir = require("@nodelib/fs.scandir");
const fastq = require("fastq");
const common = require("./common");
const reader_1 = require("./reader");
class AsyncReader extends reader_1.default {
constructor(_root, _settings) {
super(_root, _settings);
this._settings = _settings;
this._scandir = fsScandir.scandir;
this._emitter = new events_1.EventEmitter();
this._queue = fastq(this._worker.bind(this), this._settings.concurrency);
this._isFatalError = false;
this._isDestroyed = false;
this._queue.drain = () => {
if (!this._isFatalError) {
this._emitter.emit('end');
}
};
}
read() {
this._isFatalError = false;
this._isDestroyed = false;
setImmediate(() => {
this._pushToQueue(this._root, this._settings.basePath);
});
return this._emitter;
}
get isDestroyed() {
return this._isDestroyed;
}
destroy() {
if (this._isDestroyed) {
throw new Error('The reader is already destroyed');
}
this._isDestroyed = true;
this._queue.killAndDrain();
}
onEntry(callback) {
this._emitter.on('entry', callback);
}
onError(callback) {
this._emitter.once('error', callback);
}
onEnd(callback) {
this._emitter.once('end', callback);
}
_pushToQueue(directory, base) {
const queueItem = { directory, base };
this._queue.push(queueItem, (error) => {
if (error !== null) {
this._handleError(error);
}
});
}
_worker(item, done) {
this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
if (error !== null) {
return done(error, undefined);
}
for (const entry of entries) {
this._handleEntry(entry, item.base);
}
done(null, undefined);
});
}
_handleError(error) {
if (this._isDestroyed || !common.isFatalError(this._settings, error)) {
return;
}
this._isFatalError = true;
this._isDestroyed = true;
this._emitter.emit('error', error);
}
_handleEntry(entry, base) {
if (this._isDestroyed || this._isFatalError) {
return;
}
const fullpath = entry.path;
if (base !== undefined) {
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
}
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
this._emitEntry(entry);
}
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
this._pushToQueue(fullpath, entry.path);
}
}
_emitEntry(entry) {
this._emitter.emit('entry', entry);
}
}
exports.default = AsyncReader;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=async.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"async.spec.d.ts","sourceRoot":"","sources":["../../src/readers/async.spec.ts"],"names":[],"mappings":""}

165
node_modules/@nodelib/fs.walk/out/readers/async.spec.js generated vendored Normal file
View File

@@ -0,0 +1,165 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const sinon = require("sinon");
const settings_1 = require("../settings");
const tests = require("../tests");
const async_1 = require("./async");
class TestReader extends async_1.default {
constructor(_root, _settings = new settings_1.default()) {
super(_root, _settings);
this._scandir = sinon.stub();
}
get scandir() {
return this._scandir;
}
}
describe('Readers → Async', () => {
describe('.read', () => {
it('should emit "error" event when the first call of scandir is broken', (done) => {
const reader = new TestReader('non-exist-directory');
reader.scandir.yields(tests.EPERM_ERRNO);
reader.onError((error) => {
assert.ok(error);
done();
});
reader.read();
});
it('should emit "end" event when the first call of scandir is broken but this error can be suppressed', (done) => {
const settings = new settings_1.default({
errorFilter: (error) => error.code === 'EPERM'
});
const reader = new TestReader('non-exist-directory', settings);
reader.scandir.yields(tests.EPERM_ERRNO);
reader.onEnd(() => {
done();
});
reader.read();
});
it('should do not emit events after first broken scandir call', (done) => {
const reader = new TestReader('directory');
const firstFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'a', path: 'directory/a' });
const secondFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'b', path: 'directory/b' });
reader.scandir.onFirstCall().yields(null, [firstFakeDirectoryEntry, secondFakeDirectoryEntry]);
reader.scandir.onSecondCall().yieldsAsync(tests.EPERM_ERRNO);
reader.scandir.onThirdCall().yieldsAsync(tests.EPERM_ERRNO);
/**
* If the behavior is broken, then a third scandir call will trigger an unhandled error.
*/
reader.onError((error) => {
assert.ok(error);
done();
});
reader.read();
});
it('should return entries', (done) => {
const reader = new TestReader('directory');
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.deepStrictEqual(entries, [fakeDirectoryEntry, fakeFileEntry]);
done();
});
reader.read();
});
it('should push to results only directories', (done) => {
const settings = new settings_1.default({ entryFilter: (entry) => !entry.dirent.isFile() });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.deepStrictEqual(entries, [fakeDirectoryEntry]);
done();
});
reader.read();
});
it('should do not read root directory', (done) => {
const settings = new settings_1.default({ deepFilter: () => false });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.deepStrictEqual(entries, [fakeDirectoryEntry]);
done();
});
reader.read();
});
it('should set base path to entry when the `basePath` option is exist', (done) => {
const settings = new settings_1.default({ basePath: 'base' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.strictEqual(entries[0].path, path.join('base', fakeDirectoryEntry.name));
assert.strictEqual(entries[1].path, path.join('base', 'fake', fakeFileEntry.name));
done();
});
reader.read();
});
it('should set base path to entry when the `basePath` option is exist and value is an empty string', (done) => {
const settings = new settings_1.default({ basePath: '' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.strictEqual(entries[0].path, path.join(fakeDirectoryEntry.name));
assert.strictEqual(entries[1].path, path.join('fake', fakeFileEntry.name));
done();
});
reader.read();
});
});
describe('.destroy', () => {
it('should do not emit entries after destroy', (done) => {
const reader = new TestReader('directory');
const firstFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'a', path: 'directory/a' });
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [firstFakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
reader.onEntry((entry) => {
if (entry.name === 'a') {
reader.destroy();
}
else {
assert.fail('should do not emit entries after destroy');
}
});
reader.onEnd(() => {
done();
});
reader.read();
});
it('should mark stream as "destroyed" after first destroy', () => {
const reader = new TestReader('directory');
reader.destroy();
assert.ok(reader.isDestroyed);
});
it('should throw an error when trying to destroy reader twice', () => {
const reader = new TestReader('directory');
const expectedErrorMessageRe = /The reader is already destroyed/;
reader.destroy();
assert.throws(() => reader.destroy(), expectedErrorMessageRe);
});
});
});

View File

@@ -0,0 +1,7 @@
import Settings, { FilterFunction } from '../settings';
import { Errno } from '../types';
export declare function isFatalError(settings: Settings, error: Errno): boolean;
export declare function isAppliedFilter<T>(filter: FilterFunction<T> | null, value: T): boolean;
export declare function replacePathSegmentSeparator(filepath: string, separator: string): string;
export declare function joinPathSegments(a: string, b: string, separator: string): string;
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/readers/common.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,EAAE,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAMtE;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAEtF;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvF;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAahF"}

31
node_modules/@nodelib/fs.walk/out/readers/common.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0;
function isFatalError(settings, error) {
if (settings.errorFilter === null) {
return true;
}
return !settings.errorFilter(error);
}
exports.isFatalError = isFatalError;
function isAppliedFilter(filter, value) {
return filter === null || filter(value);
}
exports.isAppliedFilter = isAppliedFilter;
function replacePathSegmentSeparator(filepath, separator) {
return filepath.split(/[/\\]/).join(separator);
}
exports.replacePathSegmentSeparator = replacePathSegmentSeparator;
function joinPathSegments(a, b, separator) {
if (a === '') {
return b;
}
/**
* The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
*/
if (a.endsWith(separator)) {
return a + b;
}
return a + separator + b;
}
exports.joinPathSegments = joinPathSegments;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=common.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.spec.d.ts","sourceRoot":"","sources":["../../src/readers/common.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const settings_1 = require("../settings");
const tests = require("../tests");
const common = require("./common");
describe('Readers → Common', () => {
describe('.isFatalError', () => {
it('should return true when filter is not defined', () => {
const settings = new settings_1.default();
const actual = common.isFatalError(settings, tests.EPERM_ERRNO);
assert.ok(actual);
});
it('should return true when the error cannot be suppressed', () => {
const settings = new settings_1.default({
errorFilter: (error) => error.code === 'ENOENT'
});
const actual = common.isFatalError(settings, tests.EPERM_ERRNO);
assert.ok(actual);
});
it('should return false when the error can be suppressed', () => {
const settings = new settings_1.default({
errorFilter: (error) => error.code === 'EPERM'
});
const actual = common.isFatalError(settings, tests.EPERM_ERRNO);
assert.ok(!actual);
});
});
describe('.isAppliedFilter', () => {
it('should return true when the filter is not defined', () => {
const settings = new settings_1.default();
const entry = tests.buildFakeFileEntry();
const actual = common.isAppliedFilter(settings.entryFilter, entry);
assert.ok(actual);
});
it('should return true when the entry will be applied', () => {
const settings = new settings_1.default({
entryFilter: (entry) => entry.name === 'fake.txt'
});
const fakeEntry = tests.buildFakeFileEntry();
const actual = common.isAppliedFilter(settings.entryFilter, fakeEntry);
assert.ok(actual);
});
it('should return false when the entry will be skipped', () => {
const settings = new settings_1.default({
entryFilter: (entry) => entry.name !== 'fake.txt'
});
const fakeEntry = tests.buildFakeFileEntry();
const actual = common.isAppliedFilter(settings.entryFilter, fakeEntry);
assert.ok(!actual);
});
});
describe('.replacePathSegmentSeparator', () => {
it('should replace path segment separator', () => {
const filepath = path.join('directory', 'file.txt');
const expected = 'directory_file.txt';
const actual = common.replacePathSegmentSeparator(filepath, '_');
assert.strictEqual(actual, expected);
});
});
describe('.joinPathSegments', () => {
it('should return concatenated string', () => {
const expected = 'a&b';
const actual = common.joinPathSegments('a', 'b', '&');
assert.strictEqual(actual, expected);
});
it('should return second part of path when the first path is an empty string', () => {
const expected = 'b';
const actual = common.joinPathSegments('', 'b', '&');
assert.strictEqual(actual, expected);
});
it('should return correct string when the first segment ens with the separator symbol', () => {
// Unix
assert.strictEqual(common.joinPathSegments('/', 'a', '/'), '/a');
assert.strictEqual(common.joinPathSegments('//', 'a', '/'), '//a');
assert.strictEqual(common.joinPathSegments('/a/', 'b', '/'), '/a/b');
// Windows
assert.strictEqual(common.joinPathSegments('C:/', 'Users', '/'), 'C:/Users');
assert.strictEqual(common.joinPathSegments('C:\\', 'Users', '\\'), 'C:\\Users');
assert.strictEqual(common.joinPathSegments('//?/C:/', 'Users', '/'), '//?/C:/Users');
assert.strictEqual(common.joinPathSegments('\\\\?\\C:\\', 'Users', '\\'), '\\\\?\\C:\\Users');
});
});
});

View File

@@ -0,0 +1,7 @@
import Settings from '../settings';
export default class Reader {
protected readonly _root: string;
protected readonly _settings: Settings;
constructor(_root: string, _settings: Settings);
}
//# sourceMappingURL=reader.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/readers/reader.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,MAAM,CAAC,OAAO,OAAO,MAAM;IACd,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ;gBAArD,KAAK,EAAE,MAAM,EAAqB,SAAS,EAAE,QAAQ;CAGpF"}

11
node_modules/@nodelib/fs.walk/out/readers/reader.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const common = require("./common");
class Reader {
constructor(_root, _settings) {
this._root = _root;
this._settings = _settings;
this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
}
}
exports.default = Reader;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=reader.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reader.spec.d.ts","sourceRoot":"","sources":["../../src/readers/reader.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const settings_1 = require("../settings");
const reader_1 = require("./reader");
class TestReader extends reader_1.default {
get root() {
return this._root;
}
}
function getReader(root, options = {}) {
return new TestReader(root, new settings_1.default(options));
}
describe('Readers → Reader', () => {
describe('Constructor', () => {
it('should return root path with replaced path segment separators', () => {
const root = path.join('directory', 'file.txt');
const reader = getReader(root, { pathSegmentSeparator: '_' });
const expected = 'directory_file.txt';
const actual = reader.root;
assert.strictEqual(actual, expected);
});
});
});

16
node_modules/@nodelib/fs.walk/out/readers/sync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import * as fsScandir from '@nodelib/fs.scandir';
import { Entry } from '../types';
import Reader from './reader';
export default class SyncReader extends Reader {
protected readonly _scandir: typeof fsScandir.scandirSync;
private readonly _storage;
private readonly _queue;
read(): Entry[];
private _pushToQueue;
private _handleQueue;
private _handleDirectory;
private _handleError;
private _handleEntry;
private _pushToStorage;
}
//# sourceMappingURL=sync.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/readers/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAoB,MAAM,UAAU,CAAC;AAEnD,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,MAAM;IAC7C,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,WAAW,CAAyB;IAElF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAE7C,IAAI,IAAI,KAAK,EAAE;IAOtB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,gBAAgB;IAYxB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,cAAc;CAGtB"}

59
node_modules/@nodelib/fs.walk/out/readers/sync.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fsScandir = require("@nodelib/fs.scandir");
const common = require("./common");
const reader_1 = require("./reader");
class SyncReader extends reader_1.default {
constructor() {
super(...arguments);
this._scandir = fsScandir.scandirSync;
this._storage = new Set();
this._queue = new Set();
}
read() {
this._pushToQueue(this._root, this._settings.basePath);
this._handleQueue();
return [...this._storage];
}
_pushToQueue(directory, base) {
this._queue.add({ directory, base });
}
_handleQueue() {
for (const item of this._queue.values()) {
this._handleDirectory(item.directory, item.base);
}
}
_handleDirectory(directory, base) {
try {
const entries = this._scandir(directory, this._settings.fsScandirSettings);
for (const entry of entries) {
this._handleEntry(entry, base);
}
}
catch (error) {
this._handleError(error);
}
}
_handleError(error) {
if (!common.isFatalError(this._settings, error)) {
return;
}
throw error;
}
_handleEntry(entry, base) {
const fullpath = entry.path;
if (base !== undefined) {
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
}
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
this._pushToStorage(entry);
}
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
this._pushToQueue(fullpath, entry.path);
}
}
_pushToStorage(entry) {
this._storage.add(entry);
}
}
exports.default = SyncReader;

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=sync.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"sync.spec.d.ts","sourceRoot":"","sources":["../../src/readers/sync.spec.ts"],"names":[],"mappings":""}

89
node_modules/@nodelib/fs.walk/out/readers/sync.spec.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const sinon = require("sinon");
const settings_1 = require("../settings");
const tests = require("../tests");
const sync_1 = require("./sync");
class TestReader extends sync_1.default {
constructor(_root, _settings = new settings_1.default()) {
super(_root, _settings);
this._scandir = sinon.stub();
}
get scandir() {
return this._scandir;
}
}
describe('Readers → Sync', () => {
describe('.read', () => {
it('should throw an error when the first call of scandir is broken', () => {
const reader = new TestReader('non-exist-directory');
reader.scandir.throws(tests.EPERM_ERRNO);
assert.throws(() => reader.read(), { code: 'EPERM' });
});
it('should return empty array when the first call of scandir is broken but this error can be suppressed', () => {
const settings = new settings_1.default({
errorFilter: (error) => error.code === 'EPERM'
});
const reader = new TestReader('non-exist-directory', settings);
reader.scandir.throws(tests.EPERM_ERRNO);
const actual = reader.read();
assert.deepStrictEqual(actual, []);
});
it('should return entries', () => {
const reader = new TestReader('directory');
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const expected = [fakeDirectoryEntry, fakeFileEntry];
const actual = reader.read();
assert.deepStrictEqual(actual, expected);
});
it('should push to results only directories', () => {
const settings = new settings_1.default({ entryFilter: (entry) => !entry.dirent.isFile() });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const expected = [fakeDirectoryEntry];
const actual = reader.read();
assert.deepStrictEqual(actual, expected);
});
it('should do not read root directory', () => {
const settings = new settings_1.default({ deepFilter: () => false });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const expected = [fakeDirectoryEntry];
const actual = reader.read();
assert.deepStrictEqual(actual, expected);
});
it('should set base path to entry when the `basePath` option is exist', () => {
const settings = new settings_1.default({ basePath: 'base' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const actual = reader.read();
assert.strictEqual(actual[0].path, path.join('base', fakeDirectoryEntry.name));
assert.strictEqual(actual[1].path, path.join('base', 'fake', fakeFileEntry.name));
});
it('should set base path to entry when the `basePath` option is exist and value is an empty string', () => {
const settings = new settings_1.default({ basePath: '' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const actual = reader.read();
assert.strictEqual(actual[0].path, fakeDirectoryEntry.name);
assert.strictEqual(actual[1].path, path.join('fake', fakeFileEntry.name));
});
});
});

31
node_modules/@nodelib/fs.walk/out/settings.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
import * as fsScandir from '@nodelib/fs.scandir';
import { Entry, Errno } from './types';
export declare type FilterFunction<T> = (value: T) => boolean;
export declare type DeepFilterFunction = FilterFunction<Entry>;
export declare type EntryFilterFunction = FilterFunction<Entry>;
export declare type ErrorFilterFunction = FilterFunction<Errno>;
export declare type Options = {
basePath?: string;
concurrency?: number;
deepFilter?: DeepFilterFunction;
entryFilter?: EntryFilterFunction;
errorFilter?: ErrorFilterFunction;
followSymbolicLinks?: boolean;
fs?: Partial<fsScandir.FileSystemAdapter>;
pathSegmentSeparator?: string;
stats?: boolean;
throwErrorOnBrokenSymbolicLink?: boolean;
};
export default class Settings {
private readonly _options;
readonly basePath?: string;
readonly concurrency: number;
readonly deepFilter: DeepFilterFunction | null;
readonly entryFilter: EntryFilterFunction | null;
readonly errorFilter: ErrorFilterFunction | null;
readonly pathSegmentSeparator: string;
readonly fsScandirSettings: fsScandir.Settings;
constructor(_options?: Options);
private _getValue;
}
//# sourceMappingURL=settings.d.ts.map

1
node_modules/@nodelib/fs.walk/out/settings.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEvC,oBAAY,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AACtD,oBAAY,kBAAkB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AACvD,oBAAY,mBAAmB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AACxD,oBAAY,mBAAmB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAExD,oBAAY,OAAO,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,EAAE,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC1C,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8BAA8B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAQ;IAgBhB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAfrC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAqD;IACtF,SAAgB,WAAW,EAAE,MAAM,CAAuD;IAC1F,SAAgB,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAkD;IACvG,SAAgB,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAmD;IAC1G,SAAgB,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAmD;IAC1G,SAAgB,oBAAoB,EAAE,MAAM,CAAgE;IAE5G,SAAgB,iBAAiB,EAAE,SAAS,CAAC,QAAQ,CAMlD;gBAE0B,QAAQ,GAAE,OAAY;IAEnD,OAAO,CAAC,SAAS;CAGjB"}

26
node_modules/@nodelib/fs.walk/out/settings.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const fsScandir = require("@nodelib/fs.scandir");
class Settings {
constructor(_options = {}) {
this._options = _options;
this.basePath = this._getValue(this._options.basePath, undefined);
this.concurrency = this._getValue(this._options.concurrency, Infinity);
this.deepFilter = this._getValue(this._options.deepFilter, null);
this.entryFilter = this._getValue(this._options.entryFilter, null);
this.errorFilter = this._getValue(this._options.errorFilter, null);
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep);
this.fsScandirSettings = new fsScandir.Settings({
followSymbolicLinks: this._options.followSymbolicLinks,
fs: this._options.fs,
pathSegmentSeparator: this._options.pathSegmentSeparator,
stats: this._options.stats,
throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
});
}
_getValue(option, value) {
return option !== null && option !== void 0 ? option : value;
}
}
exports.default = Settings;

2
node_modules/@nodelib/fs.walk/out/settings.spec.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=settings.spec.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"settings.spec.d.ts","sourceRoot":"","sources":["../src/settings.spec.ts"],"names":[],"mappings":""}

28
node_modules/@nodelib/fs.walk/out/settings.spec.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const fsScandir = require("@nodelib/fs.scandir");
const settings_1 = require("./settings");
describe('Settings', () => {
it('should return instance with default values', () => {
const fsWalkSettings = new settings_1.default();
const fsScandirSettings = new fsScandir.Settings({
followSymbolicLinks: undefined,
fs: undefined,
pathSegmentSeparator: undefined,
stats: undefined,
throwErrorOnBrokenSymbolicLink: undefined
});
assert.strictEqual(fsWalkSettings.basePath, undefined);
assert.strictEqual(fsWalkSettings.concurrency, Infinity);
assert.strictEqual(fsWalkSettings.deepFilter, null);
assert.strictEqual(fsWalkSettings.entryFilter, null);
assert.strictEqual(fsWalkSettings.errorFilter, null);
assert.deepStrictEqual(fsWalkSettings.fsScandirSettings, fsScandirSettings);
});
it('should return instance with custom values', () => {
const filter = () => true;
const fsWalkSettings = new settings_1.default({ entryFilter: filter });
assert.strictEqual(fsWalkSettings.entryFilter, filter);
});
});

16
node_modules/@nodelib/fs.walk/out/tests/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import * as sinon from 'sinon';
import { Entry, Errno } from '../types';
export declare function buildFakeFileEntry(entry?: Partial<Entry>): Entry;
export declare function buildFakeDirectoryEntry(entry?: Partial<Entry>): Entry;
export declare const EPERM_ERRNO: Errno;
export declare class TestAsyncReader {
read: sinon.SinonStub;
destroy: sinon.SinonStub;
onError: sinon.SinonStub;
onEntry: sinon.SinonStub;
onEnd: sinon.SinonStub;
}
export declare class TestSyncReader {
read: sinon.SinonStub;
}
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAExC,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAOhE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAOrE;AAED,eAAO,MAAM,WAAW,EAAE,KAIzB,CAAC;AAEF,qBAAa,eAAe;IACpB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAgB;IACrC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAgB;IACxC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAgB;IACxC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAgB;IACxC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAgB;CAC7C;AAED,qBAAa,cAAc;IACnB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAgB;CAC5C"}

34
node_modules/@nodelib/fs.walk/out/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestSyncReader = exports.TestAsyncReader = exports.EPERM_ERRNO = exports.buildFakeDirectoryEntry = exports.buildFakeFileEntry = void 0;
const sinon = require("sinon");
const fs_macchiato_1 = require("../../../fs.macchiato");
function buildFakeFileEntry(entry) {
return Object.assign({ name: 'fake.txt', path: 'directory/fake.txt', dirent: new fs_macchiato_1.Dirent({ name: 'fake.txt' }) }, entry);
}
exports.buildFakeFileEntry = buildFakeFileEntry;
function buildFakeDirectoryEntry(entry) {
return Object.assign({ name: 'fake', path: 'directory/fake', dirent: new fs_macchiato_1.Dirent({ name: 'fake', isFile: false, isDirectory: true }) }, entry);
}
exports.buildFakeDirectoryEntry = buildFakeDirectoryEntry;
exports.EPERM_ERRNO = {
name: 'EPERM',
code: 'EPERM',
message: 'EPERM'
};
class TestAsyncReader {
constructor() {
this.read = sinon.stub();
this.destroy = sinon.stub();
this.onError = sinon.stub();
this.onEntry = sinon.stub();
this.onEnd = sinon.stub();
}
}
exports.TestAsyncReader = TestAsyncReader;
class TestSyncReader {
constructor() {
this.read = sinon.stub();
}
}
exports.TestSyncReader = TestSyncReader;

9
node_modules/@nodelib/fs.walk/out/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
/// <reference types="node" />
import * as scandir from '@nodelib/fs.scandir';
export declare type Entry = scandir.Entry;
export declare type Errno = NodeJS.ErrnoException;
export declare type QueueItem = {
directory: string;
base?: string;
};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAE/C,oBAAY,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAClC,oBAAY,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;AAE1C,oBAAY,SAAS,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC"}

2
node_modules/@nodelib/fs.walk/out/types/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

67
node_modules/@nodelib/fs.walk/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"_args": [
[
"@nodelib/fs.walk@1.2.6",
"/workspaces/upload-google-play"
]
],
"_from": "@nodelib/fs.walk@1.2.6",
"_id": "@nodelib/fs.walk@1.2.6",
"_inBundle": false,
"_integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==",
"_location": "/@nodelib/fs.walk",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nodelib/fs.walk@1.2.6",
"name": "@nodelib/fs.walk",
"escapedName": "@nodelib%2ffs.walk",
"scope": "@nodelib",
"rawSpec": "1.2.6",
"saveSpec": null,
"fetchSpec": "1.2.6"
},
"_requiredBy": [
"/fast-glob"
],
"_resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz",
"_spec": "1.2.6",
"_where": "/workspaces/upload-google-play",
"dependencies": {
"@nodelib/fs.scandir": "2.1.4",
"fastq": "^1.6.0"
},
"description": "A library for efficiently walking a directory recursively",
"engines": {
"node": ">= 8"
},
"gitHead": "bd149ea6dc1ef18c234730278271f6a7f3882ed2",
"keywords": [
"NodeLib",
"fs",
"FileSystem",
"file system",
"walk",
"scanner",
"crawler"
],
"license": "MIT",
"main": "out/index.js",
"name": "@nodelib/fs.walk",
"repository": {
"type": "git",
"url": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk"
},
"scripts": {
"build": "npm run clean && npm run compile && npm run lint && npm test",
"clean": "rimraf {tsconfig.tsbuildinfo,out}",
"compile": "tsc -b .",
"compile:watch": "tsc -p . --watch --sourceMap",
"lint": "eslint \"src/**/*.ts\" --cache",
"test": "mocha \"out/**/*.spec.js\" -s 0",
"watch": "npm run clean && npm run compile:watch"
},
"typings": "out/index.d.ts",
"version": "1.2.6"
}

129
node_modules/@nodelib/fs.walk/src/index.spec.ts generated vendored Normal file
View File

@@ -0,0 +1,129 @@
import * as assert from 'assert';
import * as fs from 'fs';
import { Readable } from 'stream';
import * as rimraf from 'rimraf';
import { Errno } from './types';
import { walk, walkSync, walkStream, Settings, Entry } from '.';
const entryFilter = (entry: Entry): boolean => !entry.dirent.isDirectory();
function streamToPromise(stream: Readable): Promise<Entry[]> {
const entries: Entry[] = [];
return new Promise((resolve, reject) => {
stream.on('data', (entry: Entry) => entries.push(entry));
stream.once('error', reject);
stream.once('end', () => resolve(entries));
});
}
describe('Package', () => {
before(() => {
rimraf.sync('fixtures');
fs.mkdirSync('fixtures');
fs.writeFileSync('fixtures/file.txt', '');
fs.mkdirSync('fixtures/nested');
fs.writeFileSync('fixtures/nested/file.txt', '');
});
after(() => {
rimraf.sync('fixtures');
});
describe('.walk', () => {
it('should throw an error for non-exist directory', (done) => {
walk('non-exist-directory', (error, entries) => {
assert.strictEqual(error.code, 'ENOENT');
assert.strictEqual(entries, undefined);
done();
});
});
it('should work without options or settings', (done) => {
walk('fixtures', (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 3);
done();
});
});
it('should work with options', (done) => {
walk('fixtures', { entryFilter }, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
done();
});
});
it('should work with settings', (done) => {
const settings = new Settings({ entryFilter });
walk('fixtures', settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
done();
});
});
});
describe('.walkStream', () => {
it('should throw an error for non-exist directory', async () => {
const stream = walkStream('non-exist-directory');
await assert.rejects(() => streamToPromise(stream), (error: Errno) => error.code === 'ENOENT');
});
it('should work without options or settings', async () => {
const stream = walkStream('fixtures');
const actual = await streamToPromise(stream);
assert.strictEqual(actual.length, 3);
});
it('should work with options', async () => {
const stream = walkStream('fixtures', { entryFilter });
const actual = await streamToPromise(stream);
assert.strictEqual(actual.length, 2);
});
it('should work with settings', async () => {
const settings = new Settings({ entryFilter });
const stream = walkStream('fixtures', settings);
const actual = await streamToPromise(stream);
assert.strictEqual(actual.length, 2);
});
});
describe('.walkSync', () => {
it('should throw an error for non-exist directory', () => {
const matcher = (error: Errno): boolean => error.code === 'ENOENT';
assert.throws(() => walkSync('non-exist-directory'), matcher);
});
it('should work without options or settings', () => {
const actual = walkSync('fixtures');
assert.strictEqual(actual.length, 3);
});
it('should work with options', () => {
const actual = walkSync('fixtures', { entryFilter });
assert.strictEqual(actual.length, 2);
});
it('should work with settings', () => {
const settings = new Settings({ entryFilter });
const actual = walkSync('fixtures', settings);
assert.strictEqual(actual.length, 2);
});
});
});

63
node_modules/@nodelib/fs.walk/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import { Readable } from 'stream';
import { Dirent, FileSystemAdapter } from '@nodelib/fs.scandir';
import AsyncProvider, { AsyncCallback } from './providers/async';
import StreamProvider from './providers/stream';
import SyncProvider from './providers/sync';
import Settings, { DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction, Options } from './settings';
import { Entry } from './types';
function walk(directory: string, callback: AsyncCallback): void;
function walk(directory: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
function walk(directory: string, optionsOrSettingsOrCallback: Options | Settings | AsyncCallback, callback?: AsyncCallback): void {
if (typeof optionsOrSettingsOrCallback === 'function') {
return new AsyncProvider(directory, getSettings()).read(optionsOrSettingsOrCallback);
}
new AsyncProvider(directory, getSettings(optionsOrSettingsOrCallback)).read(callback as AsyncCallback);
}
// https://github.com/typescript-eslint/typescript-eslint/issues/60
// eslint-disable-next-line no-redeclare
declare namespace walk {
function __promisify__(directory: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
}
function walkSync(directory: string, optionsOrSettings?: Options | Settings): Entry[] {
const settings = getSettings(optionsOrSettings);
const provider = new SyncProvider(directory, settings);
return provider.read();
}
function walkStream(directory: string, optionsOrSettings?: Options | Settings): Readable {
const settings = getSettings(optionsOrSettings);
const provider = new StreamProvider(directory, settings);
return provider.read();
}
function getSettings(settingsOrOptions: Settings | Options = {}): Settings {
if (settingsOrOptions instanceof Settings) {
return settingsOrOptions;
}
return new Settings(settingsOrOptions);
}
export {
walk,
walkSync,
walkStream,
Settings,
AsyncCallback,
Dirent,
Entry,
FileSystemAdapter,
Options,
DeepFilterFunction,
EntryFilterFunction,
ErrorFilterFunction
};

View File

@@ -0,0 +1,57 @@
import * as assert from 'assert';
import * as sinon from 'sinon';
import AsyncReader from '../readers/async';
import Settings from '../settings';
import * as tests from '../tests';
import AsyncProvider from './async';
class TestProvider extends AsyncProvider {
protected readonly _reader: AsyncReader = new tests.TestAsyncReader() as unknown as AsyncReader;
constructor(_root: string, _settings: Settings = new Settings()) {
super(_root, _settings);
}
public get reader(): tests.TestAsyncReader {
return this._reader as unknown as tests.TestAsyncReader;
}
}
describe('Providers → Async', () => {
describe('.read', () => {
it('should call reader function with correct set of arguments', () => {
const provider = new TestProvider('directory');
const fakeCallback = sinon.stub();
provider.read(fakeCallback);
assert.ok(provider.reader.read.called);
});
it('should call callback with error for failed launch', () => {
const provider = new TestProvider('directory');
const fakeCallback = sinon.stub();
provider.reader.onError.yields(tests.EPERM_ERRNO);
provider.read(fakeCallback);
assert.deepStrictEqual(fakeCallback.args, [[tests.EPERM_ERRNO]]);
});
it('should push entries to storage and call callback with array of entries', () => {
const provider = new TestProvider('directory');
const fakeEntry = tests.buildFakeFileEntry();
const fakeCallback = sinon.stub();
provider.reader.onEntry.yields(fakeEntry);
provider.reader.onEnd.yields();
provider.read(fakeCallback);
assert.deepStrictEqual(fakeCallback.args, [[null, [fakeEntry]]]);
});
});
});

40
node_modules/@nodelib/fs.walk/src/providers/async.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import AsyncReader from '../readers/async';
import Settings from '../settings';
import { Entry, Errno } from '../types';
type FailureCallback = (err: Errno) => void;
type SuccessCallback = (err: null, entries: Entry[]) => void;
export type AsyncCallback = (err: Errno, entries: Entry[]) => void;
export default class AsyncProvider {
protected readonly _reader: AsyncReader = new AsyncReader(this._root, this._settings);
private readonly _storage: Set<Entry> = new Set();
constructor(private readonly _root: string, private readonly _settings: Settings) { }
public read(callback: AsyncCallback): void {
this._reader.onError((error) => {
callFailureCallback(callback, error);
});
this._reader.onEntry((entry: Entry) => {
this._storage.add(entry);
});
this._reader.onEnd(() => {
callSuccessCallback(callback, [...this._storage]);
});
this._reader.read();
}
}
function callFailureCallback(callback: AsyncCallback, error: Errno): void {
(callback as FailureCallback)(error);
}
function callSuccessCallback(callback: AsyncCallback, entries: Entry[]): void {
(callback as unknown as SuccessCallback)(null, entries);
}

9
node_modules/@nodelib/fs.walk/src/providers/index.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import AsyncProvider from './async';
import StreamProvider from './stream';
import SyncProvider from './sync';
export {
AsyncProvider,
StreamProvider,
SyncProvider
};

View File

@@ -0,0 +1,90 @@
import * as assert from 'assert';
import { Readable } from 'stream';
import * as sinon from 'sinon';
import AsyncReader from '../readers/async';
import Settings from '../settings';
import * as tests from '../tests';
import StreamProvider from './stream';
class TestProvider extends StreamProvider {
protected readonly _reader: AsyncReader = new tests.TestAsyncReader() as unknown as AsyncReader;
constructor(_root: string, _settings: Settings = new Settings()) {
super(_root, _settings);
this._stream.emit = sinon.stub();
this._stream.push = sinon.stub();
}
public get reader(): tests.TestAsyncReader {
return this._reader as unknown as tests.TestAsyncReader;
}
public get stream(): sinon.SinonStubbedInstance<Readable> {
return this._stream as unknown as sinon.SinonStubbedInstance<Readable>;
}
}
describe('Providers → Stream', () => {
describe('.read', () => {
it('should return stream', () => {
const provider = new TestProvider('directory');
const stream = provider.read();
assert.ok(stream instanceof Readable);
});
it('should call reader function with correct set of arguments', () => {
const provider = new TestProvider('directory');
provider.read();
assert.ok(provider.reader.read.called);
});
it('should re-emit the "error" event from reader', () => {
const provider = new TestProvider('directory');
provider.reader.onError.yields(tests.EPERM_ERRNO);
provider.read();
assert.deepStrictEqual(provider.stream.emit.args, [['error', tests.EPERM_ERRNO]]);
});
it('should call the "push" method with entry value for the "entry" event from reader', () => {
const provider = new TestProvider('directory');
const fakeEntry = tests.buildFakeFileEntry();
provider.reader.onEntry.yields(fakeEntry);
provider.read();
assert.deepStrictEqual(provider.stream.push.args, [[fakeEntry]]);
});
it('should call the "push" method with "null" value for the "end" event from reader', () => {
const provider = new TestProvider('directory');
provider.reader.onEnd.yields();
provider.read();
assert.deepStrictEqual(provider.stream.push.args, [[null]]);
});
it('should do not destroy reader when it is already destroyed', () => {
const provider = new TestProvider('directory');
const stream = provider.read();
stream.destroy();
assert.ok(stream.destroyed);
assert.doesNotThrow(() => stream.destroy());
});
});
});

36
node_modules/@nodelib/fs.walk/src/providers/stream.ts generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import { Readable } from 'stream';
import AsyncReader from '../readers/async';
import Settings from '../settings';
export default class StreamProvider {
protected readonly _reader: AsyncReader = new AsyncReader(this._root, this._settings);
protected readonly _stream: Readable = new Readable({
objectMode: true,
read: () => { /* noop */ },
destroy: () => {
if (!this._reader.isDestroyed) {
this._reader.destroy();
}
}
});
constructor(private readonly _root: string, private readonly _settings: Settings) { }
public read(): Readable {
this._reader.onError((error) => {
this._stream.emit('error', error);
});
this._reader.onEntry((entry) => {
this._stream.push(entry);
});
this._reader.onEnd(() => {
this._stream.push(null);
});
this._reader.read();
return this._stream;
}
}

View File

@@ -0,0 +1,34 @@
import * as assert from 'assert';
import SyncReader from '../readers/sync';
import Settings from '../settings';
import * as tests from '../tests';
import SyncProvider from './sync';
class TestProvider extends SyncProvider {
protected readonly _reader: SyncReader = new tests.TestSyncReader() as unknown as SyncReader;
constructor(_root: string, _settings: Settings = new Settings()) {
super(_root, _settings);
}
public get reader(): tests.TestSyncReader {
return this._reader as unknown as tests.TestSyncReader;
}
}
describe('Providers → Sync', () => {
describe('.read', () => {
it('should call reader function with correct set of arguments and got result', () => {
const provider = new TestProvider('directory');
const fakeEntry = tests.buildFakeFileEntry();
provider.reader.read.returns([fakeEntry]);
const actual = provider.read();
assert.deepStrictEqual(actual, [fakeEntry]);
assert.ok(provider.reader.read.called);
});
});
});

13
node_modules/@nodelib/fs.walk/src/providers/sync.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import SyncReader from '../readers/sync';
import Settings from '../settings';
import { Entry } from '../types';
export default class SyncProvider {
protected readonly _reader: SyncReader = new SyncReader(this._root, this._settings);
constructor(private readonly _root: string, private readonly _settings: Settings) { }
public read(): Entry[] {
return this._reader.read();
}
}

232
node_modules/@nodelib/fs.walk/src/readers/async.spec.ts generated vendored Normal file
View File

@@ -0,0 +1,232 @@
import * as assert from 'assert';
import * as path from 'path';
import * as fsScandir from '@nodelib/fs.scandir';
import * as sinon from 'sinon';
import Settings from '../settings';
import * as tests from '../tests';
import { Entry } from '../types';
import AsyncReader from './async';
type ScandirSignature = typeof fsScandir.scandir;
class TestReader extends AsyncReader {
protected readonly _scandir: ScandirSignature = sinon.stub() as unknown as ScandirSignature;
constructor(_root: string, _settings: Settings = new Settings()) {
super(_root, _settings);
}
public get scandir(): sinon.SinonStub {
return this._scandir as unknown as sinon.SinonStub;
}
}
describe('Readers → Async', () => {
describe('.read', () => {
it('should emit "error" event when the first call of scandir is broken', (done) => {
const reader = new TestReader('non-exist-directory');
reader.scandir.yields(tests.EPERM_ERRNO);
reader.onError((error) => {
assert.ok(error);
done();
});
reader.read();
});
it('should emit "end" event when the first call of scandir is broken but this error can be suppressed', (done) => {
const settings = new Settings({
errorFilter: (error) => error.code === 'EPERM'
});
const reader = new TestReader('non-exist-directory', settings);
reader.scandir.yields(tests.EPERM_ERRNO);
reader.onEnd(() => {
done();
});
reader.read();
});
it('should do not emit events after first broken scandir call', (done) => {
const reader = new TestReader('directory');
const firstFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'a', path: 'directory/a' });
const secondFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'b', path: 'directory/b' });
reader.scandir.onFirstCall().yields(null, [firstFakeDirectoryEntry, secondFakeDirectoryEntry]);
reader.scandir.onSecondCall().yieldsAsync(tests.EPERM_ERRNO);
reader.scandir.onThirdCall().yieldsAsync(tests.EPERM_ERRNO);
/**
* If the behavior is broken, then a third scandir call will trigger an unhandled error.
*/
reader.onError((error) => {
assert.ok(error);
done();
});
reader.read();
});
it('should return entries', (done) => {
const reader = new TestReader('directory');
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries: Entry[] = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.deepStrictEqual(entries, [fakeDirectoryEntry, fakeFileEntry]);
done();
});
reader.read();
});
it('should push to results only directories', (done) => {
const settings = new Settings({ entryFilter: (entry) => !entry.dirent.isFile() });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries: Entry[] = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.deepStrictEqual(entries, [fakeDirectoryEntry]);
done();
});
reader.read();
});
it('should do not read root directory', (done) => {
const settings = new Settings({ deepFilter: () => false });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries: Entry[] = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.deepStrictEqual(entries, [fakeDirectoryEntry]);
done();
});
reader.read();
});
it('should set base path to entry when the `basePath` option is exist', (done) => {
const settings = new Settings({ basePath: 'base' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries: Entry[] = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.strictEqual(entries[0].path, path.join('base', fakeDirectoryEntry.name));
assert.strictEqual(entries[1].path, path.join('base', 'fake', fakeFileEntry.name));
done();
});
reader.read();
});
it('should set base path to entry when the `basePath` option is exist and value is an empty string', (done) => {
const settings = new Settings({ basePath: '' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [fakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
const entries: Entry[] = [];
reader.onEntry((entry) => entries.push(entry));
reader.onEnd(() => {
assert.strictEqual(entries[0].path, path.join(fakeDirectoryEntry.name));
assert.strictEqual(entries[1].path, path.join('fake', fakeFileEntry.name));
done();
});
reader.read();
});
});
describe('.destroy', () => {
it('should do not emit entries after destroy', (done) => {
const reader = new TestReader('directory');
const firstFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'a', path: 'directory/a' });
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().yields(null, [firstFakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(null, [fakeFileEntry]);
reader.onEntry((entry) => {
if (entry.name === 'a') {
reader.destroy();
} else {
assert.fail('should do not emit entries after destroy');
}
});
reader.onEnd(() => {
done();
});
reader.read();
});
it('should mark stream as "destroyed" after first destroy', () => {
const reader = new TestReader('directory');
reader.destroy();
assert.ok(reader.isDestroyed);
});
it('should throw an error when trying to destroy reader twice', () => {
const reader = new TestReader('directory');
const expectedErrorMessageRe = /The reader is already destroyed/;
reader.destroy();
assert.throws(() => reader.destroy(), expectedErrorMessageRe);
});
});
});

126
node_modules/@nodelib/fs.walk/src/readers/async.ts generated vendored Normal file
View File

@@ -0,0 +1,126 @@
import { EventEmitter } from 'events';
import * as fsScandir from '@nodelib/fs.scandir';
import * as fastq from 'fastq';
import Settings from '../settings';
import { Entry, Errno, QueueItem } from '../types';
import * as common from './common';
import Reader from './reader';
type EntryEventCallback = (entry: Entry) => void;
type ErrorEventCallback = (error: Errno) => void;
type EndEventCallback = () => void;
export default class AsyncReader extends Reader {
protected readonly _scandir: typeof fsScandir.scandir = fsScandir.scandir;
protected readonly _emitter: EventEmitter = new EventEmitter();
private readonly _queue: fastq.queue = fastq(this._worker.bind(this), this._settings.concurrency);
private _isFatalError: boolean = false;
private _isDestroyed: boolean = false;
constructor(_root: string, protected readonly _settings: Settings) {
super(_root, _settings);
this._queue.drain = () => {
if (!this._isFatalError) {
this._emitter.emit('end');
}
};
}
public read(): EventEmitter {
this._isFatalError = false;
this._isDestroyed = false;
setImmediate(() => {
this._pushToQueue(this._root, this._settings.basePath);
});
return this._emitter;
}
public get isDestroyed(): boolean {
return this._isDestroyed;
}
public destroy(): void {
if (this._isDestroyed) {
throw new Error('The reader is already destroyed');
}
this._isDestroyed = true;
this._queue.killAndDrain();
}
public onEntry(callback: EntryEventCallback): void {
this._emitter.on('entry', callback);
}
public onError(callback: ErrorEventCallback): void {
this._emitter.once('error', callback);
}
public onEnd(callback: EndEventCallback): void {
this._emitter.once('end', callback);
}
private _pushToQueue(directory: string, base?: string): void {
const queueItem: QueueItem = { directory, base };
this._queue.push(queueItem, (error: Error | null) => {
if (error !== null) {
this._handleError(error);
}
});
}
private _worker(item: QueueItem, done: fastq.done): void {
this._scandir(item.directory, this._settings.fsScandirSettings, (error: NodeJS.ErrnoException | null, entries) => {
if (error !== null) {
return done(error, undefined);
}
for (const entry of entries) {
this._handleEntry(entry, item.base);
}
done(null as unknown as Error, undefined);
});
}
private _handleError(error: Error): void {
if (this._isDestroyed || !common.isFatalError(this._settings, error)) {
return;
}
this._isFatalError = true;
this._isDestroyed = true;
this._emitter.emit('error', error);
}
private _handleEntry(entry: Entry, base?: string): void {
if (this._isDestroyed || this._isFatalError) {
return;
}
const fullpath = entry.path;
if (base !== undefined) {
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
}
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
this._emitEntry(entry);
}
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
this._pushToQueue(fullpath, entry.path);
}
}
private _emitEntry(entry: Entry): void {
this._emitter.emit('entry', entry);
}
}

View File

@@ -0,0 +1,114 @@
import * as assert from 'assert';
import * as path from 'path';
import Settings from '../settings';
import * as tests from '../tests';
import * as common from './common';
describe('Readers → Common', () => {
describe('.isFatalError', () => {
it('should return true when filter is not defined', () => {
const settings = new Settings();
const actual = common.isFatalError(settings, tests.EPERM_ERRNO);
assert.ok(actual);
});
it('should return true when the error cannot be suppressed', () => {
const settings = new Settings({
errorFilter: (error) => error.code === 'ENOENT'
});
const actual = common.isFatalError(settings, tests.EPERM_ERRNO);
assert.ok(actual);
});
it('should return false when the error can be suppressed', () => {
const settings = new Settings({
errorFilter: (error) => error.code === 'EPERM'
});
const actual = common.isFatalError(settings, tests.EPERM_ERRNO);
assert.ok(!actual);
});
});
describe('.isAppliedFilter', () => {
it('should return true when the filter is not defined', () => {
const settings = new Settings();
const entry = tests.buildFakeFileEntry();
const actual = common.isAppliedFilter(settings.entryFilter, entry);
assert.ok(actual);
});
it('should return true when the entry will be applied', () => {
const settings = new Settings({
entryFilter: (entry) => entry.name === 'fake.txt'
});
const fakeEntry = tests.buildFakeFileEntry();
const actual = common.isAppliedFilter(settings.entryFilter, fakeEntry);
assert.ok(actual);
});
it('should return false when the entry will be skipped', () => {
const settings = new Settings({
entryFilter: (entry) => entry.name !== 'fake.txt'
});
const fakeEntry = tests.buildFakeFileEntry();
const actual = common.isAppliedFilter(settings.entryFilter, fakeEntry);
assert.ok(!actual);
});
});
describe('.replacePathSegmentSeparator', () => {
it('should replace path segment separator', () => {
const filepath = path.join('directory', 'file.txt');
const expected = 'directory_file.txt';
const actual = common.replacePathSegmentSeparator(filepath, '_');
assert.strictEqual(actual, expected);
});
});
describe('.joinPathSegments', () => {
it('should return concatenated string', () => {
const expected = 'a&b';
const actual = common.joinPathSegments('a', 'b', '&');
assert.strictEqual(actual, expected);
});
it('should return second part of path when the first path is an empty string', () => {
const expected = 'b';
const actual = common.joinPathSegments('', 'b', '&');
assert.strictEqual(actual, expected);
});
it('should return correct string when the first segment ens with the separator symbol', () => {
// Unix
assert.strictEqual(common.joinPathSegments('/', 'a', '/'), '/a');
assert.strictEqual(common.joinPathSegments('//', 'a', '/'), '//a');
assert.strictEqual(common.joinPathSegments('/a/', 'b', '/'), '/a/b');
// Windows
assert.strictEqual(common.joinPathSegments('C:/', 'Users', '/'), 'C:/Users');
assert.strictEqual(common.joinPathSegments('C:\\', 'Users', '\\'), 'C:\\Users');
assert.strictEqual(common.joinPathSegments('//?/C:/', 'Users', '/'), '//?/C:/Users');
assert.strictEqual(common.joinPathSegments('\\\\?\\C:\\', 'Users', '\\'), '\\\\?\\C:\\Users');
});
});
});

33
node_modules/@nodelib/fs.walk/src/readers/common.ts generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import Settings, { FilterFunction } from '../settings';
import { Errno } from '../types';
export function isFatalError(settings: Settings, error: Errno): boolean {
if (settings.errorFilter === null) {
return true;
}
return !settings.errorFilter(error);
}
export function isAppliedFilter<T>(filter: FilterFunction<T> | null, value: T): boolean {
return filter === null || filter(value);
}
export function replacePathSegmentSeparator(filepath: string, separator: string): string {
return filepath.split(/[/\\]/).join(separator);
}
export function joinPathSegments(a: string, b: string, separator: string): string {
if (a === '') {
return b;
}
/**
* The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
*/
if (a.endsWith(separator)) {
return a + b;
}
return a + separator + b;
}

View File

@@ -0,0 +1,30 @@
import * as assert from 'assert';
import * as path from 'path';
import Settings, { Options } from '../settings';
import Reader from './reader';
class TestReader extends Reader {
public get root(): string {
return this._root;
}
}
function getReader(root: string, options: Options = {}): TestReader {
return new TestReader(root, new Settings(options));
}
describe('Readers → Reader', () => {
describe('Constructor', () => {
it('should return root path with replaced path segment separators', () => {
const root = path.join('directory', 'file.txt');
const reader = getReader(root, { pathSegmentSeparator: '_' });
const expected = 'directory_file.txt';
const actual = reader.root;
assert.strictEqual(actual, expected);
});
});
});

8
node_modules/@nodelib/fs.walk/src/readers/reader.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import Settings from '../settings';
import * as common from './common';
export default class Reader {
constructor(protected readonly _root: string, protected readonly _settings: Settings) {
this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
}
}

126
node_modules/@nodelib/fs.walk/src/readers/sync.spec.ts generated vendored Normal file
View File

@@ -0,0 +1,126 @@
import * as assert from 'assert';
import * as path from 'path';
import * as sinon from 'sinon';
import Settings from '../settings';
import * as tests from '../tests';
import SyncReader from './sync';
class TestReader extends SyncReader {
protected readonly _scandir: sinon.SinonStub = sinon.stub();
constructor(_root: string, _settings: Settings = new Settings()) {
super(_root, _settings);
}
public get scandir(): sinon.SinonStub {
return this._scandir;
}
}
describe('Readers → Sync', () => {
describe('.read', () => {
it('should throw an error when the first call of scandir is broken', () => {
const reader = new TestReader('non-exist-directory');
reader.scandir.throws(tests.EPERM_ERRNO);
assert.throws(() => reader.read(), { code: 'EPERM' });
});
it('should return empty array when the first call of scandir is broken but this error can be suppressed', () => {
const settings = new Settings({
errorFilter: (error) => error.code === 'EPERM'
});
const reader = new TestReader('non-exist-directory', settings);
reader.scandir.throws(tests.EPERM_ERRNO);
const actual = reader.read();
assert.deepStrictEqual(actual, []);
});
it('should return entries', () => {
const reader = new TestReader('directory');
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const expected = [fakeDirectoryEntry, fakeFileEntry];
const actual = reader.read();
assert.deepStrictEqual(actual, expected);
});
it('should push to results only directories', () => {
const settings = new Settings({ entryFilter: (entry) => !entry.dirent.isFile() });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const expected = [fakeDirectoryEntry];
const actual = reader.read();
assert.deepStrictEqual(actual, expected);
});
it('should do not read root directory', () => {
const settings = new Settings({ deepFilter: () => false });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const expected = [fakeDirectoryEntry];
const actual = reader.read();
assert.deepStrictEqual(actual, expected);
});
it('should set base path to entry when the `basePath` option is exist', () => {
const settings = new Settings({ basePath: 'base' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const actual = reader.read();
assert.strictEqual(actual[0].path, path.join('base', fakeDirectoryEntry.name));
assert.strictEqual(actual[1].path, path.join('base', 'fake', fakeFileEntry.name));
});
it('should set base path to entry when the `basePath` option is exist and value is an empty string', () => {
const settings = new Settings({ basePath: '' });
const reader = new TestReader('directory', settings);
const fakeDirectoryEntry = tests.buildFakeDirectoryEntry();
const fakeFileEntry = tests.buildFakeFileEntry();
reader.scandir.onFirstCall().returns([fakeDirectoryEntry]);
reader.scandir.onSecondCall().returns([fakeFileEntry]);
const actual = reader.read();
assert.strictEqual(actual[0].path, fakeDirectoryEntry.name);
assert.strictEqual(actual[1].path, path.join('fake', fakeFileEntry.name));
});
});
});

69
node_modules/@nodelib/fs.walk/src/readers/sync.ts generated vendored Normal file
View File

@@ -0,0 +1,69 @@
import * as fsScandir from '@nodelib/fs.scandir';
import { Entry, Errno, QueueItem } from '../types';
import * as common from './common';
import Reader from './reader';
export default class SyncReader extends Reader {
protected readonly _scandir: typeof fsScandir.scandirSync = fsScandir.scandirSync;
private readonly _storage: Set<Entry> = new Set();
private readonly _queue: Set<QueueItem> = new Set();
public read(): Entry[] {
this._pushToQueue(this._root, this._settings.basePath);
this._handleQueue();
return [...this._storage];
}
private _pushToQueue(directory: string, base?: string): void {
this._queue.add({ directory, base });
}
private _handleQueue(): void {
for (const item of this._queue.values()) {
this._handleDirectory(item.directory, item.base);
}
}
private _handleDirectory(directory: string, base?: string): void {
try {
const entries = this._scandir(directory, this._settings.fsScandirSettings);
for (const entry of entries) {
this._handleEntry(entry, base);
}
} catch (error) {
this._handleError(error as Errno);
}
}
private _handleError(error: Errno): void {
if (!common.isFatalError(this._settings, error)) {
return;
}
throw error;
}
private _handleEntry(entry: Entry, base?: string): void {
const fullpath = entry.path;
if (base !== undefined) {
entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
}
if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
this._pushToStorage(entry);
}
if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
this._pushToQueue(fullpath, entry.path);
}
}
private _pushToStorage(entry: Entry): void {
this._storage.add(entry);
}
}

33
node_modules/@nodelib/fs.walk/src/settings.spec.ts generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import * as assert from 'assert';
import * as fsScandir from '@nodelib/fs.scandir';
import Settings from './settings';
describe('Settings', () => {
it('should return instance with default values', () => {
const fsWalkSettings = new Settings();
const fsScandirSettings = new fsScandir.Settings({
followSymbolicLinks: undefined,
fs: undefined,
pathSegmentSeparator: undefined,
stats: undefined,
throwErrorOnBrokenSymbolicLink: undefined
});
assert.strictEqual(fsWalkSettings.basePath, undefined);
assert.strictEqual(fsWalkSettings.concurrency, Infinity);
assert.strictEqual(fsWalkSettings.deepFilter, null);
assert.strictEqual(fsWalkSettings.entryFilter, null);
assert.strictEqual(fsWalkSettings.errorFilter, null);
assert.deepStrictEqual(fsWalkSettings.fsScandirSettings, fsScandirSettings);
});
it('should return instance with custom values', () => {
const filter = (): boolean => true;
const fsWalkSettings = new Settings({ entryFilter: filter });
assert.strictEqual(fsWalkSettings.entryFilter, filter);
});
});

46
node_modules/@nodelib/fs.walk/src/settings.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import * as path from 'path';
import * as fsScandir from '@nodelib/fs.scandir';
import { Entry, Errno } from './types';
export type FilterFunction<T> = (value: T) => boolean;
export type DeepFilterFunction = FilterFunction<Entry>;
export type EntryFilterFunction = FilterFunction<Entry>;
export type ErrorFilterFunction = FilterFunction<Errno>;
export type Options = {
basePath?: string;
concurrency?: number;
deepFilter?: DeepFilterFunction;
entryFilter?: EntryFilterFunction;
errorFilter?: ErrorFilterFunction;
followSymbolicLinks?: boolean;
fs?: Partial<fsScandir.FileSystemAdapter>;
pathSegmentSeparator?: string;
stats?: boolean;
throwErrorOnBrokenSymbolicLink?: boolean;
};
export default class Settings {
public readonly basePath?: string = this._getValue(this._options.basePath, undefined);
public readonly concurrency: number = this._getValue(this._options.concurrency, Infinity);
public readonly deepFilter: DeepFilterFunction | null = this._getValue(this._options.deepFilter, null);
public readonly entryFilter: EntryFilterFunction | null = this._getValue(this._options.entryFilter, null);
public readonly errorFilter: ErrorFilterFunction | null = this._getValue(this._options.errorFilter, null);
public readonly pathSegmentSeparator: string = this._getValue(this._options.pathSegmentSeparator, path.sep);
public readonly fsScandirSettings: fsScandir.Settings = new fsScandir.Settings({
followSymbolicLinks: this._options.followSymbolicLinks,
fs: this._options.fs,
pathSegmentSeparator: this._options.pathSegmentSeparator,
stats: this._options.stats,
throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink
});
constructor(private readonly _options: Options = {}) { }
private _getValue<T>(option: T | undefined, value: T): T {
return option ?? value;
}
}

40
node_modules/@nodelib/fs.walk/src/tests/index.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
import * as sinon from 'sinon';
import { Dirent } from '../../../fs.macchiato';
import { Entry, Errno } from '../types';
export function buildFakeFileEntry(entry?: Partial<Entry>): Entry {
return {
name: 'fake.txt',
path: 'directory/fake.txt',
dirent: new Dirent({ name: 'fake.txt' }),
...entry
};
}
export function buildFakeDirectoryEntry(entry?: Partial<Entry>): Entry {
return {
name: 'fake',
path: 'directory/fake',
dirent: new Dirent({ name: 'fake', isFile: false, isDirectory: true }),
...entry
};
}
export const EPERM_ERRNO: Errno = {
name: 'EPERM',
code: 'EPERM',
message: 'EPERM'
};
export class TestAsyncReader {
public read: sinon.SinonStub = sinon.stub();
public destroy: sinon.SinonStub = sinon.stub();
public onError: sinon.SinonStub = sinon.stub();
public onEntry: sinon.SinonStub = sinon.stub();
public onEnd: sinon.SinonStub = sinon.stub();
}
export class TestSyncReader {
public read: sinon.SinonStub = sinon.stub();
}

9
node_modules/@nodelib/fs.walk/src/types/index.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import * as scandir from '@nodelib/fs.scandir';
export type Entry = scandir.Entry;
export type Errno = NodeJS.ErrnoException;
export type QueueItem = {
directory: string;
base?: string;
};

15
node_modules/@nodelib/fs.walk/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "out"
},
"references": [
{
"path": "../fs.macchiato"
},
{
"path": "../fs.scandir"
}
]
}