Remove unnecessary resources, add bulma, and add AdvMakefile

This commit is contained in:
2021-03-29 15:02:41 -07:00
parent 69f2d46a8c
commit bb2c9351d6
6084 changed files with 674187 additions and 0 deletions

15
bulma/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

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
bulma/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);
}

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
bulma/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);
});
});
});

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"}

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"}

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"}

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());
});
});
});

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"}

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);
});
});
});

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"}

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":""}

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"}

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"}

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);
});
});
});

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"}

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":""}

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
bulma/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

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
bulma/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;

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":""}

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);
});
});

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
bulma/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;

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"}

View File

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