Ensuring node modules are up to date for running
This commit is contained in:
21
node_modules/@nodelib/fs.stat/LICENSE
generated
vendored
Normal file
21
node_modules/@nodelib/fs.stat/LICENSE
generated
vendored
Normal 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.
|
||||
126
node_modules/@nodelib/fs.stat/README.md
generated
vendored
Normal file
126
node_modules/@nodelib/fs.stat/README.md
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
# @nodelib/fs.stat
|
||||
|
||||
> Get the status of a file with some features.
|
||||
|
||||
## :bulb: Highlights
|
||||
|
||||
Wrapper around standard method `fs.lstat` and `fs.stat` with some features.
|
||||
|
||||
* :beginner: Normally follows symbolic link.
|
||||
* :gear: Can safely work with broken symbolic link.
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
npm install @nodelib/fs.stat
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import * as fsStat from '@nodelib/fs.stat';
|
||||
|
||||
fsStat.stat('path', (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .stat(path, [optionsOrSettings], callback)
|
||||
|
||||
Returns an instance of `fs.Stats` class for provided path with standard callback-style.
|
||||
|
||||
```ts
|
||||
fsStat.stat('path', (error, stats) => { /* … */ });
|
||||
fsStat.stat('path', {}, (error, stats) => { /* … */ });
|
||||
fsStat.stat('path', new fsStat.Settings(), (error, stats) => { /* … */ });
|
||||
```
|
||||
|
||||
### .statSync(path, [optionsOrSettings])
|
||||
|
||||
Returns an instance of `fs.Stats` class for provided path.
|
||||
|
||||
```ts
|
||||
const stats = fsStat.stat('path');
|
||||
const stats = fsStat.stat('path', {});
|
||||
const stats = fsStat.stat('path', new fsStat.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 fsStat.Settings({ followSymbolicLink: false });
|
||||
|
||||
const stats = fsStat.stat('path', settings);
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### `followSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Follow symbolic link or not. Call `fs.stat` on symbolic link if `true`.
|
||||
|
||||
### `markSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `false`
|
||||
|
||||
Mark symbolic link by setting the return value of `isSymbolicLink` function to always `true` (even after `fs.stat`).
|
||||
|
||||
> :book: Can be used if you want to know what is hidden behind a symbolic link, but still continue to know that it is a symbolic link.
|
||||
|
||||
### `throwErrorOnBrokenSymbolicLink`
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Throw an error when symbolic link is broken if `true` or safely return `lstat` call if `false`.
|
||||
|
||||
### `fs`
|
||||
|
||||
* Type: [`FileSystemAdapter`](./src/adapters/fs.ts)
|
||||
* 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;
|
||||
}
|
||||
|
||||
const settings = new fsStat.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.
|
||||
11
node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts
generated
vendored
Normal file
11
node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
export declare type FileSystemAdapter = {
|
||||
lstat: typeof fs.lstat;
|
||||
stat: typeof fs.stat;
|
||||
lstatSync: typeof fs.lstatSync;
|
||||
statSync: typeof fs.statSync;
|
||||
};
|
||||
export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
|
||||
export declare function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
|
||||
//# sourceMappingURL=fs.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/adapters/fs.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,oBAAY,iBAAiB,GAAG;IAC/B,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC;IACvB,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAKjC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CASjG"}
|
||||
17
node_modules/@nodelib/fs.stat/out/adapters/fs.js
generated
vendored
Normal file
17
node_modules/@nodelib/fs.stat/out/adapters/fs.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
||||
const fs = require("fs");
|
||||
exports.FILE_SYSTEM_ADAPTER = {
|
||||
lstat: fs.lstat,
|
||||
stat: fs.stat,
|
||||
lstatSync: fs.lstatSync,
|
||||
statSync: fs.statSync
|
||||
};
|
||||
function createFileSystemAdapter(fsMethods) {
|
||||
if (fsMethods === undefined) {
|
||||
return exports.FILE_SYSTEM_ADAPTER;
|
||||
}
|
||||
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
||||
}
|
||||
exports.createFileSystemAdapter = createFileSystemAdapter;
|
||||
2
node_modules/@nodelib/fs.stat/out/adapters/fs.spec.d.ts
generated
vendored
Normal file
2
node_modules/@nodelib/fs.stat/out/adapters/fs.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=fs.spec.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/adapters/fs.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/adapters/fs.spec.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.spec.d.ts","sourceRoot":"","sources":["../../src/adapters/fs.spec.ts"],"names":[],"mappings":""}
|
||||
20
node_modules/@nodelib/fs.stat/out/adapters/fs.spec.js
generated
vendored
Normal file
20
node_modules/@nodelib/fs.stat/out/adapters/fs.spec.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert = require("assert");
|
||||
const fs_macchiato_1 = require("../../../fs.macchiato");
|
||||
const adapter = require("./fs");
|
||||
describe('Adapters → FileSystem', () => {
|
||||
it('should return original FS methods', () => {
|
||||
const expected = adapter.FILE_SYSTEM_ADAPTER;
|
||||
const actual = adapter.createFileSystemAdapter();
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
it('should return custom FS methods', () => {
|
||||
const customLstatSyncMethod = () => new fs_macchiato_1.Stats();
|
||||
const expected = Object.assign(Object.assign({}, adapter.FILE_SYSTEM_ADAPTER), { lstatSync: customLstatSyncMethod });
|
||||
const actual = adapter.createFileSystemAdapter({
|
||||
lstatSync: customLstatSyncMethod
|
||||
});
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
13
node_modules/@nodelib/fs.stat/out/index.d.ts
generated
vendored
Normal file
13
node_modules/@nodelib/fs.stat/out/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { FileSystemAdapter } from './adapters/fs';
|
||||
import * as async from './providers/async';
|
||||
import Settings, { Options } from './settings';
|
||||
import { Stats } from './types';
|
||||
declare type AsyncCallback = async.AsyncCallback;
|
||||
declare function stat(path: string, callback: AsyncCallback): void;
|
||||
declare function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
|
||||
declare namespace stat {
|
||||
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Stats>;
|
||||
}
|
||||
declare function statSync(path: string, optionsOrSettings?: Options | Settings): Stats;
|
||||
export { Settings, stat, statSync, AsyncCallback, FileSystemAdapter, Options, Stats };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;AAEzC,iBAAS,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;AAC3D,iBAAS,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAG,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;AAWlG,OAAO,WAAW,IAAI,CAAC;IACtB,SAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CAC7F;AAED,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAI7E;AAUD,OAAO,EACN,QAAQ,EACR,IAAI,EACJ,QAAQ,EAIR,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,KAAK,EACL,CAAC"}
|
||||
25
node_modules/@nodelib/fs.stat/out/index.js
generated
vendored
Normal file
25
node_modules/@nodelib/fs.stat/out/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.statSync = exports.stat = exports.Settings = void 0;
|
||||
const async = require("./providers/async");
|
||||
const sync = require("./providers/sync");
|
||||
const settings_1 = require("./settings");
|
||||
exports.Settings = settings_1.default;
|
||||
function stat(path, optionsOrSettingsOrCallback, callback) {
|
||||
if (typeof optionsOrSettingsOrCallback === 'function') {
|
||||
return async.read(path, getSettings(), optionsOrSettingsOrCallback);
|
||||
}
|
||||
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
|
||||
}
|
||||
exports.stat = stat;
|
||||
function statSync(path, optionsOrSettings) {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
return sync.read(path, settings);
|
||||
}
|
||||
exports.statSync = statSync;
|
||||
function getSettings(settingsOrOptions = {}) {
|
||||
if (settingsOrOptions instanceof settings_1.default) {
|
||||
return settingsOrOptions;
|
||||
}
|
||||
return new settings_1.default(settingsOrOptions);
|
||||
}
|
||||
2
node_modules/@nodelib/fs.stat/out/index.spec.d.ts
generated
vendored
Normal file
2
node_modules/@nodelib/fs.stat/out/index.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=index.spec.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/index.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/index.spec.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":""}
|
||||
56
node_modules/@nodelib/fs.stat/out/index.spec.js
generated
vendored
Normal file
56
node_modules/@nodelib/fs.stat/out/index.spec.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert = require("assert");
|
||||
const fs = require("fs");
|
||||
const rimraf = require("rimraf");
|
||||
const _1 = require(".");
|
||||
describe('Package', () => {
|
||||
before(() => {
|
||||
rimraf.sync('fixtures');
|
||||
fs.mkdirSync('fixtures');
|
||||
fs.mkdirSync('fixtures/a');
|
||||
fs.symlinkSync('a', 'fixtures/b', 'junction');
|
||||
});
|
||||
after(() => {
|
||||
rimraf.sync('fixtures');
|
||||
});
|
||||
describe('.stat', () => {
|
||||
it('should work without options or settings', (done) => {
|
||||
_1.stat('fixtures/b', (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.ok(stats);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should work with options', (done) => {
|
||||
_1.stat('fixtures/b', { markSymbolicLink: true }, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.isSymbolicLink(), true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should work with settings', (done) => {
|
||||
const settings = new _1.Settings({ markSymbolicLink: true });
|
||||
_1.stat('fixtures/b', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.isSymbolicLink(), true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('.statSync', () => {
|
||||
it('should work without options or settings', () => {
|
||||
const actual = _1.statSync('fixtures/b');
|
||||
assert.ok(actual);
|
||||
});
|
||||
it('should work with options', () => {
|
||||
const actual = _1.statSync('fixtures/b', { markSymbolicLink: true });
|
||||
assert.strictEqual(actual.isSymbolicLink(), true);
|
||||
});
|
||||
it('should work with settings', () => {
|
||||
const settings = new _1.Settings({ markSymbolicLink: true });
|
||||
const actual = _1.statSync('fixtures/b', settings);
|
||||
assert.strictEqual(actual.isSymbolicLink(), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
5
node_modules/@nodelib/fs.stat/out/providers/async.d.ts
generated
vendored
Normal file
5
node_modules/@nodelib/fs.stat/out/providers/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import Settings from '../settings';
|
||||
import { ErrnoException, Stats } from '../types';
|
||||
export declare type AsyncCallback = (err: ErrnoException, stats: Stats) => void;
|
||||
export declare function read(path: string, settings: Settings, callback: AsyncCallback): void;
|
||||
//# sourceMappingURL=async.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/providers/async.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/providers/async.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/providers/async.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKjD,oBAAY,aAAa,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAExE,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CA0BpF"}
|
||||
32
node_modules/@nodelib/fs.stat/out/providers/async.js
generated
vendored
Normal file
32
node_modules/@nodelib/fs.stat/out/providers/async.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.read = void 0;
|
||||
function read(path, settings, callback) {
|
||||
settings.fs.lstat(path, (lstatError, lstat) => {
|
||||
if (lstatError !== null) {
|
||||
return callFailureCallback(callback, lstatError);
|
||||
}
|
||||
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
||||
return callSuccessCallback(callback, lstat);
|
||||
}
|
||||
settings.fs.stat(path, (statError, stat) => {
|
||||
if (statError !== null) {
|
||||
if (settings.throwErrorOnBrokenSymbolicLink) {
|
||||
return callFailureCallback(callback, statError);
|
||||
}
|
||||
return callSuccessCallback(callback, lstat);
|
||||
}
|
||||
if (settings.markSymbolicLink) {
|
||||
stat.isSymbolicLink = () => true;
|
||||
}
|
||||
callSuccessCallback(callback, stat);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.read = read;
|
||||
function callFailureCallback(callback, error) {
|
||||
callback(error);
|
||||
}
|
||||
function callSuccessCallback(callback, result) {
|
||||
callback(null, result);
|
||||
}
|
||||
2
node_modules/@nodelib/fs.stat/out/providers/async.spec.d.ts
generated
vendored
Normal file
2
node_modules/@nodelib/fs.stat/out/providers/async.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=async.spec.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/providers/async.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/providers/async.spec.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"async.spec.d.ts","sourceRoot":"","sources":["../../src/providers/async.spec.ts"],"names":[],"mappings":""}
|
||||
83
node_modules/@nodelib/fs.stat/out/providers/async.spec.js
generated
vendored
Normal file
83
node_modules/@nodelib/fs.stat/out/providers/async.spec.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert = require("assert");
|
||||
const sinon = require("sinon");
|
||||
const fs_macchiato_1 = require("../../../fs.macchiato");
|
||||
const settings_1 = require("../settings");
|
||||
const provider = require("./async");
|
||||
describe('Providers → Async', () => {
|
||||
describe('.read', () => {
|
||||
it('should return lstat for non-symlink entry', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new fs_macchiato_1.Stats());
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstat }
|
||||
});
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return lstat for symlink entry when the "followSymbolicLink" option is disabled', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const settings = new settings_1.default({
|
||||
followSymbolicLink: false,
|
||||
fs: { lstat }
|
||||
});
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return stat for symlink entry', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const stat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ ino: 1 }));
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstat, stat }
|
||||
});
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return marked stat for symlink entry when the "markSymbolicLink" option is enabled', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const stat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ ino: 1 }));
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstat, stat },
|
||||
markSymbolicLink: true
|
||||
});
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.isSymbolicLink(), true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should return lstat for broken symlink entry when the "throwErrorOnBrokenSymbolicLink" option is disabled', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const stat = sinon.stub().yields(new Error());
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstat, stat },
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
});
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should throw an error when symlink entry is broken', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const stat = sinon.stub().yields(new Error('broken'));
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstat, stat }
|
||||
});
|
||||
provider.read('filepath', settings, (error) => {
|
||||
assert.strictEqual(error.message, 'broken');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
4
node_modules/@nodelib/fs.stat/out/providers/sync.d.ts
generated
vendored
Normal file
4
node_modules/@nodelib/fs.stat/out/providers/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import Settings from '../settings';
|
||||
import { Stats } from '../types';
|
||||
export declare function read(path: string, settings: Settings): Stats;
|
||||
//# sourceMappingURL=sync.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/providers/sync.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/providers/sync.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/providers/sync.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAsB5D"}
|
||||
23
node_modules/@nodelib/fs.stat/out/providers/sync.js
generated
vendored
Normal file
23
node_modules/@nodelib/fs.stat/out/providers/sync.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.read = void 0;
|
||||
function read(path, settings) {
|
||||
const lstat = settings.fs.lstatSync(path);
|
||||
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
||||
return lstat;
|
||||
}
|
||||
try {
|
||||
const stat = settings.fs.statSync(path);
|
||||
if (settings.markSymbolicLink) {
|
||||
stat.isSymbolicLink = () => true;
|
||||
}
|
||||
return stat;
|
||||
}
|
||||
catch (error) {
|
||||
if (!settings.throwErrorOnBrokenSymbolicLink) {
|
||||
return lstat;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
exports.read = read;
|
||||
2
node_modules/@nodelib/fs.stat/out/providers/sync.spec.d.ts
generated
vendored
Normal file
2
node_modules/@nodelib/fs.stat/out/providers/sync.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=sync.spec.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/providers/sync.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/providers/sync.spec.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sync.spec.d.ts","sourceRoot":"","sources":["../../src/providers/sync.spec.ts"],"names":[],"mappings":""}
|
||||
66
node_modules/@nodelib/fs.stat/out/providers/sync.spec.js
generated
vendored
Normal file
66
node_modules/@nodelib/fs.stat/out/providers/sync.spec.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert = require("assert");
|
||||
const sinon = require("sinon");
|
||||
const fs_macchiato_1 = require("../../../fs.macchiato");
|
||||
const settings_1 = require("../settings");
|
||||
const provider = require("./sync");
|
||||
describe('Providers → Sync', () => {
|
||||
describe('.read', () => {
|
||||
it('should return lstat for non-symlink entry', () => {
|
||||
const lstatSync = sinon.stub().returns(new fs_macchiato_1.Stats());
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstatSync }
|
||||
});
|
||||
const actual = provider.read('filepath', settings);
|
||||
assert.strictEqual(actual.ino, 0);
|
||||
});
|
||||
it('should return lstat for symlink entry when the "followSymbolicLink" option is disabled', () => {
|
||||
const lstatSync = sinon.stub().returns(new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const settings = new settings_1.default({
|
||||
followSymbolicLink: false,
|
||||
fs: { lstatSync }
|
||||
});
|
||||
const actual = provider.read('filepath', settings);
|
||||
assert.strictEqual(actual.ino, 0);
|
||||
});
|
||||
it('should return stat for symlink entry', () => {
|
||||
const lstatSync = sinon.stub().returns(new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().returns(new fs_macchiato_1.Stats({ ino: 1 }));
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstatSync, statSync }
|
||||
});
|
||||
const actual = provider.read('filepath', settings);
|
||||
assert.strictEqual(actual.ino, 1);
|
||||
});
|
||||
it('should return marked stat for symlink entry when the "markSymbolicLink" option is enabled', () => {
|
||||
const lstatSync = sinon.stub().returns(new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().returns(new fs_macchiato_1.Stats({ ino: 1 }));
|
||||
const settings = new settings_1.default({
|
||||
markSymbolicLink: true,
|
||||
fs: { lstatSync, statSync }
|
||||
});
|
||||
const actual = provider.read('filepath', settings);
|
||||
assert.strictEqual(actual.isSymbolicLink(), true);
|
||||
});
|
||||
it('should return lstat for broken symlink entry when the "throwErrorOnBrokenSymbolicLink" option is disabled', () => {
|
||||
const lstatSync = sinon.stub().returns(new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().throws(new Error('error'));
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstatSync, statSync },
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
});
|
||||
const actual = provider.read('filepath', settings);
|
||||
assert.strictEqual(actual.ino, 0);
|
||||
});
|
||||
it('should throw an error when symlink entry is broken', () => {
|
||||
const lstatSync = sinon.stub().returns(new fs_macchiato_1.Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().throws(new Error('broken'));
|
||||
const settings = new settings_1.default({
|
||||
fs: { lstatSync, statSync }
|
||||
});
|
||||
const expectedErrorMessageRe = /broken/;
|
||||
assert.throws(() => provider.read('filepath', settings), expectedErrorMessageRe);
|
||||
});
|
||||
});
|
||||
});
|
||||
17
node_modules/@nodelib/fs.stat/out/settings.d.ts
generated
vendored
Normal file
17
node_modules/@nodelib/fs.stat/out/settings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as fs from './adapters/fs';
|
||||
export declare type Options = {
|
||||
followSymbolicLink?: boolean;
|
||||
fs?: Partial<fs.FileSystemAdapter>;
|
||||
markSymbolicLink?: boolean;
|
||||
throwErrorOnBrokenSymbolicLink?: boolean;
|
||||
};
|
||||
export default class Settings {
|
||||
private readonly _options;
|
||||
readonly followSymbolicLink: boolean;
|
||||
readonly fs: fs.FileSystemAdapter;
|
||||
readonly markSymbolicLink: boolean;
|
||||
readonly throwErrorOnBrokenSymbolicLink: boolean;
|
||||
constructor(_options?: Options);
|
||||
private _getValue;
|
||||
}
|
||||
//# sourceMappingURL=settings.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/settings.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/settings.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpC,oBAAY,OAAO,GAAG;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,8BAA8B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAQ;IAMhB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IALrC,SAAgB,kBAAkB,EAAE,OAAO,CAA0D;IACrG,SAAgB,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAgD;IACxF,SAAgB,gBAAgB,EAAE,OAAO,CAAyD;IAClG,SAAgB,8BAA8B,EAAE,OAAO,CAAsE;gBAEhG,QAAQ,GAAE,OAAY;IAEnD,OAAO,CAAC,SAAS;CAGjB"}
|
||||
16
node_modules/@nodelib/fs.stat/out/settings.js
generated
vendored
Normal file
16
node_modules/@nodelib/fs.stat/out/settings.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("./adapters/fs");
|
||||
class Settings {
|
||||
constructor(_options = {}) {
|
||||
this._options = _options;
|
||||
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
||||
this.fs = fs.createFileSystemAdapter(this._options.fs);
|
||||
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
||||
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
||||
}
|
||||
_getValue(option, value) {
|
||||
return option !== null && option !== void 0 ? option : value;
|
||||
}
|
||||
}
|
||||
exports.default = Settings;
|
||||
2
node_modules/@nodelib/fs.stat/out/settings.spec.d.ts
generated
vendored
Normal file
2
node_modules/@nodelib/fs.stat/out/settings.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=settings.spec.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/settings.spec.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/settings.spec.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"settings.spec.d.ts","sourceRoot":"","sources":["../src/settings.spec.ts"],"names":[],"mappings":""}
|
||||
26
node_modules/@nodelib/fs.stat/out/settings.spec.js
generated
vendored
Normal file
26
node_modules/@nodelib/fs.stat/out/settings.spec.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert = require("assert");
|
||||
const fs_macchiato_1 = require("../../fs.macchiato");
|
||||
const fs = require("./adapters/fs");
|
||||
const settings_1 = require("./settings");
|
||||
describe('Settings', () => {
|
||||
it('should return instance with default values', () => {
|
||||
const settings = new settings_1.default();
|
||||
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter());
|
||||
assert.ok(settings.throwErrorOnBrokenSymbolicLink);
|
||||
assert.ok(!settings.markSymbolicLink);
|
||||
assert.ok(settings.followSymbolicLink);
|
||||
});
|
||||
it('should return instance with custom values', () => {
|
||||
const lstatSync = () => new fs_macchiato_1.Stats();
|
||||
const settings = new settings_1.default({
|
||||
followSymbolicLink: false,
|
||||
fs: fs.createFileSystemAdapter({ lstatSync }),
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
});
|
||||
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter({ lstatSync }));
|
||||
assert.ok(!settings.throwErrorOnBrokenSymbolicLink);
|
||||
assert.ok(!settings.followSymbolicLink);
|
||||
});
|
||||
});
|
||||
5
node_modules/@nodelib/fs.stat/out/types/index.d.ts
generated
vendored
Normal file
5
node_modules/@nodelib/fs.stat/out/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
export declare type Stats = fs.Stats;
|
||||
export declare type ErrnoException = NodeJS.ErrnoException;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/@nodelib/fs.stat/out/types/index.d.ts.map
generated
vendored
Normal file
1
node_modules/@nodelib/fs.stat/out/types/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,oBAAY,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;AAC7B,oBAAY,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC"}
|
||||
2
node_modules/@nodelib/fs.stat/out/types/index.js
generated
vendored
Normal file
2
node_modules/@nodelib/fs.stat/out/types/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
62
node_modules/@nodelib/fs.stat/package.json
generated
vendored
Normal file
62
node_modules/@nodelib/fs.stat/package.json
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@nodelib/fs.stat@2.0.4",
|
||||
"/workspaces/upload-google-play"
|
||||
]
|
||||
],
|
||||
"_from": "@nodelib/fs.stat@2.0.4",
|
||||
"_id": "@nodelib/fs.stat@2.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==",
|
||||
"_location": "/@nodelib/fs.stat",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@nodelib/fs.stat@2.0.4",
|
||||
"name": "@nodelib/fs.stat",
|
||||
"escapedName": "@nodelib%2ffs.stat",
|
||||
"scope": "@nodelib",
|
||||
"rawSpec": "2.0.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@nodelib/fs.scandir",
|
||||
"/fast-glob"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz",
|
||||
"_spec": "2.0.4",
|
||||
"_where": "/workspaces/upload-google-play",
|
||||
"description": "Get the status of a file with some features",
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
},
|
||||
"gitHead": "cb5f7e893a986164c3b847a4f1faef6c54cadd68",
|
||||
"keywords": [
|
||||
"NodeLib",
|
||||
"fs",
|
||||
"FileSystem",
|
||||
"file system",
|
||||
"stat"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "out/index.js",
|
||||
"name": "@nodelib/fs.stat",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat"
|
||||
},
|
||||
"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": "2.0.4"
|
||||
}
|
||||
31
node_modules/@nodelib/fs.stat/src/adapters/fs.spec.ts
generated
vendored
Normal file
31
node_modules/@nodelib/fs.stat/src/adapters/fs.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { Stats } from '../../../fs.macchiato';
|
||||
|
||||
import * as adapter from './fs';
|
||||
|
||||
describe('Adapters → FileSystem', () => {
|
||||
it('should return original FS methods', () => {
|
||||
const expected: adapter.FileSystemAdapter = adapter.FILE_SYSTEM_ADAPTER;
|
||||
|
||||
const actual = adapter.createFileSystemAdapter();
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('should return custom FS methods', () => {
|
||||
const customLstatSyncMethod: typeof fs.lstatSync = () => new Stats();
|
||||
|
||||
const expected: adapter.FileSystemAdapter = {
|
||||
...adapter.FILE_SYSTEM_ADAPTER,
|
||||
lstatSync: customLstatSyncMethod
|
||||
};
|
||||
|
||||
const actual = adapter.createFileSystemAdapter({
|
||||
lstatSync: customLstatSyncMethod
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(actual, expected);
|
||||
});
|
||||
});
|
||||
26
node_modules/@nodelib/fs.stat/src/adapters/fs.ts
generated
vendored
Normal file
26
node_modules/@nodelib/fs.stat/src/adapters/fs.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
export type FileSystemAdapter = {
|
||||
lstat: typeof fs.lstat;
|
||||
stat: typeof fs.stat;
|
||||
lstatSync: typeof fs.lstatSync;
|
||||
statSync: typeof fs.statSync;
|
||||
};
|
||||
|
||||
export const FILE_SYSTEM_ADAPTER: FileSystemAdapter = {
|
||||
lstat: fs.lstat,
|
||||
stat: fs.stat,
|
||||
lstatSync: fs.lstatSync,
|
||||
statSync: fs.statSync
|
||||
};
|
||||
|
||||
export function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter {
|
||||
if (fsMethods === undefined) {
|
||||
return FILE_SYSTEM_ADAPTER;
|
||||
}
|
||||
|
||||
return {
|
||||
...FILE_SYSTEM_ADAPTER,
|
||||
...fsMethods
|
||||
};
|
||||
}
|
||||
70
node_modules/@nodelib/fs.stat/src/index.spec.ts
generated
vendored
Normal file
70
node_modules/@nodelib/fs.stat/src/index.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import * as rimraf from 'rimraf';
|
||||
|
||||
import { stat, statSync, Settings } from '.';
|
||||
|
||||
describe('Package', () => {
|
||||
before(() => {
|
||||
rimraf.sync('fixtures');
|
||||
|
||||
fs.mkdirSync('fixtures');
|
||||
fs.mkdirSync('fixtures/a');
|
||||
fs.symlinkSync('a', 'fixtures/b', 'junction');
|
||||
});
|
||||
|
||||
after(() => {
|
||||
rimraf.sync('fixtures');
|
||||
});
|
||||
|
||||
describe('.stat', () => {
|
||||
it('should work without options or settings', (done) => {
|
||||
stat('fixtures/b', (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.ok(stats);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with options', (done) => {
|
||||
stat('fixtures/b', { markSymbolicLink: true }, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.isSymbolicLink(), true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with settings', (done) => {
|
||||
const settings = new Settings({ markSymbolicLink: true });
|
||||
|
||||
stat('fixtures/b', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.isSymbolicLink(), true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.statSync', () => {
|
||||
it('should work without options or settings', () => {
|
||||
const actual = statSync('fixtures/b');
|
||||
|
||||
assert.ok(actual);
|
||||
});
|
||||
|
||||
it('should work with options', () => {
|
||||
const actual = statSync('fixtures/b', { markSymbolicLink: true });
|
||||
|
||||
assert.strictEqual(actual.isSymbolicLink(), true);
|
||||
});
|
||||
|
||||
it('should work with settings', () => {
|
||||
const settings = new Settings({ markSymbolicLink: true });
|
||||
|
||||
const actual = statSync('fixtures/b', settings);
|
||||
|
||||
assert.strictEqual(actual.isSymbolicLink(), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
50
node_modules/@nodelib/fs.stat/src/index.ts
generated
vendored
Normal file
50
node_modules/@nodelib/fs.stat/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { FileSystemAdapter } from './adapters/fs';
|
||||
import * as async from './providers/async';
|
||||
import * as sync from './providers/sync';
|
||||
import Settings, { Options } from './settings';
|
||||
import { Stats } from './types';
|
||||
|
||||
type AsyncCallback = async.AsyncCallback;
|
||||
|
||||
function stat(path: string, callback: AsyncCallback): void;
|
||||
function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
|
||||
function stat(path: string, optionsOrSettingsOrCallback: Options | Settings | AsyncCallback, callback?: AsyncCallback): void {
|
||||
if (typeof optionsOrSettingsOrCallback === 'function') {
|
||||
return async.read(path, getSettings(), optionsOrSettingsOrCallback);
|
||||
}
|
||||
|
||||
async.read(path, getSettings(optionsOrSettingsOrCallback), callback as AsyncCallback);
|
||||
}
|
||||
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/60
|
||||
// eslint-disable-next-line no-redeclare
|
||||
declare namespace stat {
|
||||
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Stats>;
|
||||
}
|
||||
|
||||
function statSync(path: string, optionsOrSettings?: Options | Settings): Stats {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
|
||||
return sync.read(path, settings);
|
||||
}
|
||||
|
||||
function getSettings(settingsOrOptions: Settings | Options = {}): Settings {
|
||||
if (settingsOrOptions instanceof Settings) {
|
||||
return settingsOrOptions;
|
||||
}
|
||||
|
||||
return new Settings(settingsOrOptions);
|
||||
}
|
||||
|
||||
export {
|
||||
Settings,
|
||||
stat,
|
||||
statSync,
|
||||
|
||||
// https://github.com/typescript-eslint/typescript-eslint/issues/131
|
||||
// eslint-disable-next-line no-undef
|
||||
AsyncCallback,
|
||||
FileSystemAdapter,
|
||||
Options,
|
||||
Stats
|
||||
};
|
||||
102
node_modules/@nodelib/fs.stat/src/providers/async.spec.ts
generated
vendored
Normal file
102
node_modules/@nodelib/fs.stat/src/providers/async.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import * as assert from 'assert';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import { Stats } from '../../../fs.macchiato';
|
||||
import Settings from '../settings';
|
||||
import * as provider from './async';
|
||||
|
||||
describe('Providers → Async', () => {
|
||||
describe('.read', () => {
|
||||
it('should return lstat for non-symlink entry', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new Stats()) as unknown as typeof fs.lstat;
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstat }
|
||||
});
|
||||
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return lstat for symlink entry when the "followSymbolicLink" option is disabled', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
|
||||
|
||||
const settings = new Settings({
|
||||
followSymbolicLink: false,
|
||||
fs: { lstat }
|
||||
});
|
||||
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return stat for symlink entry', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
|
||||
const stat = sinon.stub().yields(null, new Stats({ ino: 1 })) as unknown as typeof fs.stat;
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstat, stat }
|
||||
});
|
||||
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return marked stat for symlink entry when the "markSymbolicLink" option is enabled', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
|
||||
const stat = sinon.stub().yields(null, new Stats({ ino: 1 })) as unknown as typeof fs.stat;
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstat, stat },
|
||||
markSymbolicLink: true
|
||||
});
|
||||
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.isSymbolicLink(), true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return lstat for broken symlink entry when the "throwErrorOnBrokenSymbolicLink" option is disabled', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
|
||||
const stat = sinon.stub().yields(new Error()) as unknown as typeof fs.stat;
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstat, stat },
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
});
|
||||
|
||||
provider.read('filepath', settings, (error, stats) => {
|
||||
assert.strictEqual(error, null);
|
||||
assert.strictEqual(stats.ino, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when symlink entry is broken', (done) => {
|
||||
const lstat = sinon.stub().yields(null, new Stats({ isSymbolicLink: true })) as unknown as typeof fs.lstat;
|
||||
const stat = sinon.stub().yields(new Error('broken')) as unknown as typeof fs.stat;
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstat, stat }
|
||||
});
|
||||
|
||||
provider.read('filepath', settings, (error) => {
|
||||
assert.strictEqual(error.message, 'broken');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
43
node_modules/@nodelib/fs.stat/src/providers/async.ts
generated
vendored
Normal file
43
node_modules/@nodelib/fs.stat/src/providers/async.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import Settings from '../settings';
|
||||
import { ErrnoException, Stats } from '../types';
|
||||
|
||||
type FailureCallback = (err: ErrnoException) => void;
|
||||
type SuccessCallback = (err: null, stats: Stats) => void;
|
||||
|
||||
export type AsyncCallback = (err: ErrnoException, stats: Stats) => void;
|
||||
|
||||
export function read(path: string, settings: Settings, callback: AsyncCallback): void {
|
||||
settings.fs.lstat(path, (lstatError, lstat) => {
|
||||
if (lstatError !== null) {
|
||||
return callFailureCallback(callback, lstatError);
|
||||
}
|
||||
|
||||
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
||||
return callSuccessCallback(callback, lstat);
|
||||
}
|
||||
|
||||
settings.fs.stat(path, (statError, stat) => {
|
||||
if (statError !== null) {
|
||||
if (settings.throwErrorOnBrokenSymbolicLink) {
|
||||
return callFailureCallback(callback, statError);
|
||||
}
|
||||
|
||||
return callSuccessCallback(callback, lstat);
|
||||
}
|
||||
|
||||
if (settings.markSymbolicLink) {
|
||||
stat.isSymbolicLink = () => true;
|
||||
}
|
||||
|
||||
callSuccessCallback(callback, stat);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function callFailureCallback(callback: AsyncCallback, error: ErrnoException): void {
|
||||
(callback as FailureCallback)(error);
|
||||
}
|
||||
|
||||
function callSuccessCallback(callback: AsyncCallback, result: Stats): void {
|
||||
(callback as unknown as SuccessCallback)(null, result);
|
||||
}
|
||||
90
node_modules/@nodelib/fs.stat/src/providers/sync.spec.ts
generated
vendored
Normal file
90
node_modules/@nodelib/fs.stat/src/providers/sync.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
import * as assert from 'assert';
|
||||
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import { Stats } from '../../../fs.macchiato';
|
||||
import Settings from '../settings';
|
||||
import * as provider from './sync';
|
||||
|
||||
describe('Providers → Sync', () => {
|
||||
describe('.read', () => {
|
||||
it('should return lstat for non-symlink entry', () => {
|
||||
const lstatSync = sinon.stub().returns(new Stats());
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstatSync }
|
||||
});
|
||||
|
||||
const actual = provider.read('filepath', settings);
|
||||
|
||||
assert.strictEqual(actual.ino, 0);
|
||||
});
|
||||
|
||||
it('should return lstat for symlink entry when the "followSymbolicLink" option is disabled', () => {
|
||||
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
|
||||
|
||||
const settings = new Settings({
|
||||
followSymbolicLink: false,
|
||||
fs: { lstatSync }
|
||||
});
|
||||
|
||||
const actual = provider.read('filepath', settings);
|
||||
|
||||
assert.strictEqual(actual.ino, 0);
|
||||
});
|
||||
|
||||
it('should return stat for symlink entry', () => {
|
||||
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().returns(new Stats({ ino: 1 }));
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstatSync, statSync }
|
||||
});
|
||||
|
||||
const actual = provider.read('filepath', settings);
|
||||
|
||||
assert.strictEqual(actual.ino, 1);
|
||||
});
|
||||
|
||||
it('should return marked stat for symlink entry when the "markSymbolicLink" option is enabled', () => {
|
||||
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().returns(new Stats({ ino: 1 }));
|
||||
|
||||
const settings = new Settings({
|
||||
markSymbolicLink: true,
|
||||
fs: { lstatSync, statSync }
|
||||
});
|
||||
|
||||
const actual = provider.read('filepath', settings);
|
||||
|
||||
assert.strictEqual(actual.isSymbolicLink(), true);
|
||||
});
|
||||
|
||||
it('should return lstat for broken symlink entry when the "throwErrorOnBrokenSymbolicLink" option is disabled', () => {
|
||||
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().throws(new Error('error'));
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstatSync, statSync },
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
});
|
||||
|
||||
const actual = provider.read('filepath', settings);
|
||||
|
||||
assert.strictEqual(actual.ino, 0);
|
||||
});
|
||||
|
||||
it('should throw an error when symlink entry is broken', () => {
|
||||
const lstatSync = sinon.stub().returns(new Stats({ isSymbolicLink: true }));
|
||||
const statSync = sinon.stub().throws(new Error('broken'));
|
||||
|
||||
const settings = new Settings({
|
||||
fs: { lstatSync, statSync }
|
||||
});
|
||||
|
||||
const expectedErrorMessageRe = /broken/;
|
||||
|
||||
assert.throws(() => provider.read('filepath', settings), expectedErrorMessageRe);
|
||||
});
|
||||
});
|
||||
});
|
||||
26
node_modules/@nodelib/fs.stat/src/providers/sync.ts
generated
vendored
Normal file
26
node_modules/@nodelib/fs.stat/src/providers/sync.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import Settings from '../settings';
|
||||
import { Stats } from '../types';
|
||||
|
||||
export function read(path: string, settings: Settings): Stats {
|
||||
const lstat = settings.fs.lstatSync(path);
|
||||
|
||||
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
||||
return lstat;
|
||||
}
|
||||
|
||||
try {
|
||||
const stat = settings.fs.statSync(path);
|
||||
|
||||
if (settings.markSymbolicLink) {
|
||||
stat.isSymbolicLink = () => true;
|
||||
}
|
||||
|
||||
return stat;
|
||||
} catch (error) {
|
||||
if (!settings.throwErrorOnBrokenSymbolicLink) {
|
||||
return lstat;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
31
node_modules/@nodelib/fs.stat/src/settings.spec.ts
generated
vendored
Normal file
31
node_modules/@nodelib/fs.stat/src/settings.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as assert from 'assert';
|
||||
|
||||
import { Stats } from '../../fs.macchiato';
|
||||
|
||||
import * as fs from './adapters/fs';
|
||||
import Settings from './settings';
|
||||
|
||||
describe('Settings', () => {
|
||||
it('should return instance with default values', () => {
|
||||
const settings = new Settings();
|
||||
|
||||
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter());
|
||||
assert.ok(settings.throwErrorOnBrokenSymbolicLink);
|
||||
assert.ok(!settings.markSymbolicLink);
|
||||
assert.ok(settings.followSymbolicLink);
|
||||
});
|
||||
|
||||
it('should return instance with custom values', () => {
|
||||
const lstatSync = (): Stats => new Stats();
|
||||
|
||||
const settings = new Settings({
|
||||
followSymbolicLink: false,
|
||||
fs: fs.createFileSystemAdapter({ lstatSync }),
|
||||
throwErrorOnBrokenSymbolicLink: false
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter({ lstatSync }));
|
||||
assert.ok(!settings.throwErrorOnBrokenSymbolicLink);
|
||||
assert.ok(!settings.followSymbolicLink);
|
||||
});
|
||||
});
|
||||
21
node_modules/@nodelib/fs.stat/src/settings.ts
generated
vendored
Normal file
21
node_modules/@nodelib/fs.stat/src/settings.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as fs from './adapters/fs';
|
||||
|
||||
export type Options = {
|
||||
followSymbolicLink?: boolean;
|
||||
fs?: Partial<fs.FileSystemAdapter>;
|
||||
markSymbolicLink?: boolean;
|
||||
throwErrorOnBrokenSymbolicLink?: boolean;
|
||||
};
|
||||
|
||||
export default class Settings {
|
||||
public readonly followSymbolicLink: boolean = this._getValue(this._options.followSymbolicLink, true);
|
||||
public readonly fs: fs.FileSystemAdapter = fs.createFileSystemAdapter(this._options.fs);
|
||||
public readonly markSymbolicLink: boolean = this._getValue(this._options.markSymbolicLink, false);
|
||||
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
||||
|
||||
constructor(private readonly _options: Options = {}) { }
|
||||
|
||||
private _getValue<T>(option: T | undefined, value: T): T {
|
||||
return option ?? value;
|
||||
}
|
||||
}
|
||||
4
node_modules/@nodelib/fs.stat/src/types/index.ts
generated
vendored
Normal file
4
node_modules/@nodelib/fs.stat/src/types/index.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
export type Stats = fs.Stats;
|
||||
export type ErrnoException = NodeJS.ErrnoException;
|
||||
12
node_modules/@nodelib/fs.stat/tsconfig.json
generated
vendored
Normal file
12
node_modules/@nodelib/fs.stat/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "out"
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../fs.macchiato"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user