18 Commits

Author SHA1 Message Date
Drew Heavner
edc6575646 Ensuring node modules are up to date for running 2021-03-18 14:18:40 +00:00
Drew Heavner
0bff061163 Merge pull request #63 from DiogoAbu/master
Add support for glob
2021-03-18 09:00:59 -04:00
Diogo de Azevedo Silva
49d0f39523 fix: change log message 2021-03-17 16:04:18 -03:00
Diogo de Azevedo Silva
c6ef6b1183 docs: add example using glob 2021-03-17 15:46:44 -03:00
DiogoAbu
053164334a docs: update readme 2021-03-11 20:11:42 -03:00
DiogoAbu
fbc59f2a64 fix: build lib 2021-03-11 20:11:26 -03:00
DiogoAbu
26a9aa82ba feat: allow glob on releaseFiles input 2021-03-11 19:43:14 -03:00
Drew Heavner
ace656b089 Update issue templates 2021-01-14 09:43:56 -05:00
Drew Heavner
ba5abd87ce Merge pull request #54 from boswelja/master
Remove releaseName from outputs
2021-01-06 08:58:17 -05:00
Jack Boswell (boswelja)
d4681f654d Remove releaseName from outputs in readme 2021-01-01 16:43:34 +13:00
Jack Boswell (boswelja)
bda8b09ade Remove outputting generated release name
Seems like Google doesn't expose this before edits are committed.
2021-01-01 16:42:39 +13:00
Drew Heavner
ca061d798d Merge pull request #53 from lriccardo/master
Add internal sharing download url to outputs and env
2020-12-30 15:29:09 -05:00
Riccardo Lattarulo
21e00b9d69 Update documentation to address the addition of multiple urls as output for internal sharing 2020-12-29 17:39:10 +01:00
Riccardo Lattarulo
e9a4446395 Add multiple urls to internal sharing outputs 2020-12-23 10:16:35 +01:00
Riccardo Lattarulo
b06f374506 Add internal sharing download url to output 2020-12-22 16:57:37 +01:00
Drew Heavner
84d17e8c1c Merge pull request #50 from boswelja/add-console-output
Add some output for the user to read while the action is running
2020-12-16 10:23:49 -05:00
Jack Boswell (boswelja)
40448bb1bb Add some output for the user to read while the action is running 2020-12-12 18:38:17 +13:00
Drew Heavner
2f949adc6e Removed call to developer api to pull the releaseName for the edit and instead used result from actual update to the track.
Added more debug logging.
2020-12-10 11:36:45 -05:00
318 changed files with 12617 additions and 78 deletions

33
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: r0adkll
---
**Describe the bug**
A clear and concise description of what the bug is.
**Workflow Step Configuration**
<!-- Update the example below with your configuration to better help me debug your issue. You can obfuscate anything that isn't public. -->
```yml
- name: Deploy Production
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }}
packageName: com.example.app
releaseFile: app/build/outputs/bundle/release/app-release.aab
track: production
whatsNewDirectory: distribution/whatsnew/
mappingFile: app/build/outputs/mapping/release/mapping.txt
```
**Step Debugging**
- [ ] I have enabled [Step Debug Logging](https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging)
<!-- Please post your debug step logs for this step here to better help debugging, or link to your actions if your project is open source -->

View File

@@ -19,13 +19,13 @@ The service account json in plain text, provided via a secret, etc.
**Required:** The package name, or Application Id, of the app you are uploading
### `releaseFile`
**DEPRECATED:** Please switch to using `releaseFiles` as this will be removed in the future
The Android release file to upload (.apk or .aab)
**DEPRECATED:** Please switch to using `releaseFiles` as this will be removed in the future
The Android release file to upload (.apk or .aab)
### `releaseFiles`
**CAVEAT:** Either this or `releaseFile` are required
**CAVEAT:** Either this or `releaseFile` are required
The Android release file(s) to upload (.apk or .aab). Multiple files are separated by ','.
The Android release file(s) to upload (.apk or .aab). Multiple files are separated by ','. Supports glob.
### `releaseName`
@@ -33,15 +33,15 @@ The release name. Not required to be unique. If not set, the name is generated f
### `track`
**Required:** The track in which you want to assign the uploaded app.
**Default:** `production`
**Required:** The track in which you want to assign the uploaded app.
**Default:** `production`
_Values:_ `alpha`, `beta`, `internal`, `production`, `internalsharing`
### `inAppUpdatePriority`
In-app update priority of the release. All newly added APKs in the release will be considered at this priority. Can take values in the range [0, 5], with 5 the highest priority.
**Default:** `0`
**Default:** `0`
_Values:_ `[0, 5]`
### `userFraction`
@@ -53,7 +53,7 @@ Portion of users who should get the staged version of the app. Accepts values be
The directory of localized whats new files to upload as the release notes. The files contained in the `whatsNewDirectory` MUST use the pattern `whatsnew-<LOCALE>` where `LOCALE` is using the [`BCP 47`](https://tools.ietf.org/html/bcp47) format, e.g.
* `en-US` - English/America
* `de-DE` - German/Germany
* `ja-JP` - Japanese/Japan
* `ja-JP` - Japanese/Japan
and contain plain `utf8` encoded text with no extension on the file. The resulting directory in your project should look something like this:
```
@@ -72,13 +72,17 @@ The mapping.txt file used to de-obfuscate your stack traces from crash reports
## Outputs
### `releaseName`
### `internalSharingDownloadUrls`
The name of the release published to Google Play, which is generated on commit by default
A JSON list containing the download urls for every release file uploaded using the `track` `internalsharing`
### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URLS`
The environment variable that is set when using the `track` `internalsharing`
### `internalSharingDownloadUrl`
The download url for an app that was uploaded using the `track` `internalsharing`
The download url for the last release file uploaded using the `track` `internalsharing`, useful when a single release file is uploaded
### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URL`
@@ -98,3 +102,17 @@ with:
whatsNewDirectory: distribution/whatsnew
mappingFile: app/build/outputs/mapping/release/mapping.txt
```
Using glob to get release files
```yaml
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: ${{ SERVICE_ACCOUNT_JSON }}
packageName: com.example.MyApp
releaseFiles: app/build/outputs/bundle/release/*.aab
track: production
inAppUpdatePriority: 2
userFraction: 0.33
whatsNewDirectory: distribution/whatsnew
mappingFile: app/build/outputs/mapping/release/mapping.txt
```

View File

@@ -18,7 +18,7 @@ inputs:
description: "The Android release file to upload (.apk or .aab)"
required: false
releaseFiles:
description: "The Android release file(s) to upload (.apk or .aab). Separated by a ',' for multiple artifacts"
description: "The Android release file(s) to upload (.apk or .aab). Separated by a ',' for multiple artifacts. Supports glob"
required: false
releaseName:
description: "The name of this release. If not set it's generated automatically from the APKs versionName"

View File

@@ -40,38 +40,51 @@ function uploadToPlayStore(options, releaseFiles) {
// Check the 'track' for 'internalsharing', if so switch to a non-track api
if (options.track === 'internalsharing') {
core.debug("Track is Internal app sharing, switch to special upload api");
let downloadUrls = [];
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
yield uploadInternalSharingRelease(options, releaseFile).catch(reason => {
yield uploadInternalSharingRelease(options, releaseFile)
.then(downloadUrl => {
downloadUrls.push(downloadUrl);
})
.catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
}
core.setOutput("internalSharingDownloadUrls", downloadUrls);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URLS", downloadUrls);
}
else {
// Create a new Edit
core.info(`Creating a new Edit for this release`);
const appEdit = yield androidPublisher.edits.insert({
auth: options.auth,
packageName: options.applicationId
});
// Validate the given track
core.info(`Validating track '${options.track}'`);
yield validateSelectedTrack(appEdit.data, options).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
// Upload artifacts to Google Play, and store their version codes
var versionCodes = new Array();
const versionCodes = new Array();
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
core.info(`Uploading ${releaseFile}`);
const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
versionCodes.push(versionCode);
}
core.info(`Successfully uploaded ${versionCodes.length} artifacts`);
// Add the uploaded artifacts to the Edit track
core.info(`Adding ${versionCodes.length} artifacts to release on '${options.track}' track`);
const track = yield addReleasesToTrack(appEdit.data, options, versionCodes);
core.debug(`Track: ${track}`);
// Commit the pending Edit
core.info(`Committing the Edit`);
const res = yield androidPublisher.edits.commit({
auth: options.auth,
editId: appEdit.data.id,
@@ -79,9 +92,7 @@ function uploadToPlayStore(options, releaseFiles) {
});
// Simple check to see whether commit was successful
if (res.data.id != null) {
core.debug(`Successfully committed ${res.data.id}`);
const name = options.name || (yield getPublishedReleaseName(res.data, options));
core.setOutput("releaseName", name);
core.info(`Successfully committed ${res.data.id}`);
return Promise.resolve(res.data.id);
}
else {
@@ -96,11 +107,15 @@ function uploadInternalSharingRelease(options, releaseFile) {
return __awaiter(this, void 0, void 0, function* () {
if (releaseFile.endsWith('.apk')) {
const res = yield internalSharingUploadApk(options, releaseFile);
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
}
else if (releaseFile.endsWith('.aab')) {
const res = yield internalSharingUploadBundle(options, releaseFile);
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
}
@@ -251,15 +266,3 @@ function uploadBundle(appEdit, options, bundleReleaseFile) {
return res.data;
});
}
function getPublishedReleaseName(appEdit, options) {
return __awaiter(this, void 0, void 0, function* () {
const track = yield androidPublisher.edits.tracks.get({
auth: options.auth,
packageName: options.applicationId,
editId: appEdit.id,
track: options.track
});
const release = track.data.releases[0]; // We only ever create one release, so grab the first one
return release.name;
});
}

View File

@@ -27,9 +27,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const fs = __importStar(require("fs"));
const fast_glob_1 = __importDefault(require("fast-glob"));
const edits_1 = require("./edits");
const { google } = require('googleapis');
const auth = new google.auth.GoogleAuth({
@@ -110,14 +114,13 @@ function run() {
}
}
else if (releaseFiles.length > 0) {
for (const file of releaseFiles) {
core.debug(`Validating ${file} exists`);
if (!fs.existsSync(file)) {
core.setFailed(`Unable to find release file @ ${file}`);
return;
}
core.debug(`Finding files ${releaseFiles.join(',')}`);
const files = yield fast_glob_1.default(releaseFiles);
if (!files.length) {
core.setFailed(`Unable to find any release file @ ${releaseFiles.join(',')}`);
return;
}
validatedReleaseFiles = releaseFiles;
validatedReleaseFiles = files;
}
if (whatsNewDir != undefined && whatsNewDir.length > 0 && !fs.existsSync(whatsNewDir)) {
core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`);
@@ -128,7 +131,7 @@ function run() {
return;
}
const authClient = yield auth.getClient();
yield edits_1.uploadToPlayStore({
const result = yield edits_1.uploadToPlayStore({
auth: authClient,
applicationId: packageName,
track: track,
@@ -138,7 +141,7 @@ function run() {
mappingFile: mappingFile,
name: releaseName
}, validatedReleaseFiles);
console.log(`Finished uploading to the Play Store`);
console.log(`Finished uploading to the Play Store: ${result}`);
}
catch (error) {
core.setFailed(error.message);

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

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

171
node_modules/@nodelib/fs.scandir/README.md generated vendored Normal file
View File

@@ -0,0 +1,171 @@
# @nodelib/fs.scandir
> List files and directories inside the specified directory.
## :bulb: Highlights
The package is aimed at obtaining information about entries in the directory.
* :moneybag: Returns useful information: `name`, `path`, `dirent` and `stats` (optional).
* :gear: On Node.js 10.10+ uses the mechanism without additional calls to determine the entry type. See [`old` and `modern` mode](#old-and-modern-mode).
* :link: Can safely work with broken symbolic links.
## Install
```console
npm install @nodelib/fs.scandir
```
## Usage
```ts
import * as fsScandir from '@nodelib/fs.scandir';
fsScandir.scandir('path', (error, stats) => { /* … */ });
```
## API
### .scandir(path, [optionsOrSettings], callback)
Returns an array of plain objects ([`Entry`](#entry)) with information about entry for provided path with standard callback-style.
```ts
fsScandir.scandir('path', (error, entries) => { /* … */ });
fsScandir.scandir('path', {}, (error, entries) => { /* … */ });
fsScandir.scandir('path', new fsScandir.Settings(), (error, entries) => { /* … */ });
```
### .scandirSync(path, [optionsOrSettings])
Returns an array of plain objects ([`Entry`](#entry)) with information about entry for provided path.
```ts
const entries = fsScandir.scandirSync('path');
const entries = fsScandir.scandirSync('path', {});
const entries = fsScandir.scandirSync(('path', new fsScandir.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`](#settingsoptions) 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 fsScandir.Settings({ followSymbolicLinks: false });
const entries = fsScandir.scandirSync('path', settings);
```
## Entry
* `name` — The name of the entry (`unknown.txt`).
* `path` — The path of the entry relative to call directory (`root/unknown.txt`).
* `dirent` — An instance of [`fs.Dirent`](./src/types/index.ts) class. On Node.js below 10.10 will be emulated by [`DirentFromStats`](./src/utils/fs.ts) class.
* `stats` (optional) — An instance of `fs.Stats` class.
For example, the `scandir` call for `tools` directory with one directory inside:
```ts
{
dirent: Dirent { name: 'typedoc', /* … */ },
name: 'typedoc',
path: 'tools/typedoc'
}
```
## Options
### stats
* Type: `boolean`
* Default: `false`
Adds an instance of `fs.Stats` class to the [`Entry`](#entry).
> :book: Always use `fs.readdir` without the `withFileTypes` option. ??TODO??
### followSymbolicLinks
* Type: `boolean`
* Default: `false`
Follow symbolic links or not. Call `fs.stat` on symbolic link if `true`.
### `throwErrorOnBrokenSymbolicLink`
* Type: `boolean`
* Default: `true`
Throw an error when symbolic link is broken if `true` or safely use `lstat` call if `false`.
### `pathSegmentSeparator`
* Type: `string`
* Default: `path.sep`
By default, this package uses the correct path separator for your OS (`\` on Windows, `/` on Unix-like systems). But you can set this option to any separator character(s) that you want to use instead.
### `fs`
* Type: [`FileSystemAdapter`](./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;
readdir?: typeof fs.readdir;
readdirSync?: typeof fs.readdirSync;
}
const settings = new fsScandir.Settings({
fs: { lstat: fakeLstat }
});
```
## `old` and `modern` mode
This package has two modes that are used depending on the environment and parameters of use.
### old
* Node.js below `10.10` or when the `stats` option is enabled
When working in the old mode, the directory is read first (`fs.readdir`), then the type of entries is determined (`fs.lstat` and/or `fs.stat` for symbolic links).
### modern
* Node.js 10.10+ and the `stats` option is disabled
In the modern mode, reading the directory (`fs.readdir` with the `withFileTypes` option) is combined with obtaining information about its entries. An additional call for symbolic links (`fs.stat`) is still present.
This mode makes fewer calls to the file system. It's faster.
## 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.

13
node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
/// <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;
readdir: typeof fs.readdir;
readdirSync: typeof fs.readdirSync;
};
export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
export declare function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
//# sourceMappingURL=fs.d.ts.map

View 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;IAC7B,OAAO,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC;IAC3B,WAAW,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,iBAOjC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CASjG"}

19
node_modules/@nodelib/fs.scandir/out/adapters/fs.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
"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,
readdir: fs.readdir,
readdirSync: fs.readdirSync
};
function createFileSystemAdapter(fsMethods) {
if (fsMethods === undefined) {
return exports.FILE_SYSTEM_ADAPTER;
}
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
}
exports.createFileSystemAdapter = createFileSystemAdapter;

View File

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

View File

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

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

5
node_modules/@nodelib/fs.scandir/out/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
/**
* IS `true` for Node.js 10.10 and greater.
*/
export declare const IS_SUPPORT_READDIR_WITH_FILE_TYPES: boolean;
//# sourceMappingURL=constants.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,eAAO,MAAM,kCAAkC,SAAuD,CAAC"}

14
node_modules/@nodelib/fs.scandir/out/constants.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = void 0;
const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
const SUPPORTED_MAJOR_VERSION = 10;
const SUPPORTED_MINOR_VERSION = 10;
const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
/**
* IS `true` for Node.js 10.10 and greater.
*/
exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;

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

@@ -0,0 +1,13 @@
import { FileSystemAdapter } from './adapters/fs';
import * as async from './providers/async';
import Settings, { Options } from './settings';
import { Dirent, Entry } from './types';
declare type AsyncCallback = async.AsyncCallback;
declare function scandir(path: string, callback: AsyncCallback): void;
declare function scandir(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
declare namespace scandir {
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
}
declare function scandirSync(path: string, optionsOrSettings?: Options | Settings): Entry[];
export { scandir, scandirSync, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, Options };
//# sourceMappingURL=index.d.ts.map

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

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAExC,aAAK,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;AAEzC,iBAAS,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;AAC9D,iBAAS,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAG,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;AAWrG,OAAO,WAAW,OAAO,CAAC;IACzB,SAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;CAC/F;AAED,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,EAAE,CAIlF;AAUD,OAAO,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EAIR,aAAa,EACb,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,OAAO,EACP,CAAC"}

25
node_modules/@nodelib/fs.scandir/out/index.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Settings = exports.scandirSync = exports.scandir = void 0;
const async = require("./providers/async");
const sync = require("./providers/sync");
const settings_1 = require("./settings");
exports.Settings = settings_1.default;
function scandir(path, optionsOrSettingsOrCallback, callback) {
if (typeof optionsOrSettingsOrCallback === 'function') {
return async.read(path, getSettings(), optionsOrSettingsOrCallback);
}
async.read(path, getSettings(optionsOrSettingsOrCallback), callback);
}
exports.scandir = scandir;
function scandirSync(path, optionsOrSettings) {
const settings = getSettings(optionsOrSettings);
return sync.read(path, settings);
}
exports.scandirSync = scandirSync;
function getSettings(settingsOrOptions = {}) {
if (settingsOrOptions instanceof settings_1.default) {
return settingsOrOptions;
}
return new settings_1.default(settingsOrOptions);
}

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

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

View File

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

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

@@ -0,0 +1,71 @@
"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.writeFileSync('fixtures/file.txt', '');
});
after(() => {
rimraf.sync('fixtures');
});
describe('.scandir', () => {
it('should work without options or settings', (done) => {
_1.scandir('fixtures', (error, entries) => {
assert.strictEqual(error, null);
assert.ok(entries[0].name);
assert.ok(entries[0].path);
assert.ok(entries[0].dirent);
done();
});
});
it('should work with options', (done) => {
_1.scandir('fixtures', { stats: true }, (error, entries) => {
assert.strictEqual(error, null);
assert.ok(entries[0].name);
assert.ok(entries[0].path);
assert.ok(entries[0].dirent);
assert.ok(entries[0].stats);
done();
});
});
it('should work with settings', (done) => {
const settings = new _1.Settings({ stats: true });
_1.scandir('fixtures', settings, (error, entries) => {
assert.strictEqual(error, null);
assert.ok(entries[0].name);
assert.ok(entries[0].path);
assert.ok(entries[0].dirent);
assert.ok(entries[0].stats);
done();
});
});
});
describe('.scandirSync', () => {
it('should work without options or settings', () => {
const actual = _1.scandirSync('fixtures');
assert.ok(actual[0].name);
assert.ok(actual[0].path);
assert.ok(actual[0].dirent);
});
it('should work with options', () => {
const actual = _1.scandirSync('fixtures', { stats: true });
assert.ok(actual[0].name);
assert.ok(actual[0].path);
assert.ok(actual[0].dirent);
assert.ok(actual[0].stats);
});
it('should work with settings', () => {
const settings = new _1.Settings({ stats: true });
const actual = _1.scandirSync('fixtures', settings);
assert.ok(actual[0].name);
assert.ok(actual[0].path);
assert.ok(actual[0].dirent);
assert.ok(actual[0].stats);
});
});
});

View File

@@ -0,0 +1,8 @@
/// <reference types="node" />
import Settings from '../settings';
import { Entry } from '../types';
export declare type AsyncCallback = (err: NodeJS.ErrnoException, entries: Entry[]) => void;
export declare function read(directory: string, settings: Settings, callback: AsyncCallback): void;
export declare function readdirWithFileTypes(directory: string, settings: Settings, callback: AsyncCallback): void;
export declare function readdir(directory: string, settings: Settings, 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":";AAIA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAS,MAAM,UAAU,CAAC;AASxC,oBAAY,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;AAEnF,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAMzF;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CA0BzG;AAwBD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAsC5F"}

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
const fsStat = require("@nodelib/fs.stat");
const rpl = require("run-parallel");
const constants_1 = require("../constants");
const utils = require("../utils");
const common = require("./common");
function read(directory, settings, callback) {
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
return readdirWithFileTypes(directory, settings, callback);
}
return readdir(directory, settings, callback);
}
exports.read = read;
function readdirWithFileTypes(directory, settings, callback) {
settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => {
if (readdirError !== null) {
return callFailureCallback(callback, readdirError);
}
const entries = dirents.map((dirent) => ({
dirent,
name: dirent.name,
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
}));
if (!settings.followSymbolicLinks) {
return callSuccessCallback(callback, entries);
}
const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings));
rpl(tasks, (rplError, rplEntries) => {
if (rplError !== null) {
return callFailureCallback(callback, rplError);
}
callSuccessCallback(callback, rplEntries);
});
});
}
exports.readdirWithFileTypes = readdirWithFileTypes;
function makeRplTaskEntry(entry, settings) {
return (done) => {
if (!entry.dirent.isSymbolicLink()) {
return done(null, entry);
}
settings.fs.stat(entry.path, (statError, stats) => {
if (statError !== null) {
if (settings.throwErrorOnBrokenSymbolicLink) {
return done(statError);
}
return done(null, entry);
}
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
return done(null, entry);
});
};
}
function readdir(directory, settings, callback) {
settings.fs.readdir(directory, (readdirError, names) => {
if (readdirError !== null) {
return callFailureCallback(callback, readdirError);
}
const filepaths = names.map((name) => common.joinPathSegments(directory, name, settings.pathSegmentSeparator));
const tasks = filepaths.map((filepath) => {
return (done) => fsStat.stat(filepath, settings.fsStatSettings, done);
});
rpl(tasks, (rplError, results) => {
if (rplError !== null) {
return callFailureCallback(callback, rplError);
}
const entries = [];
names.forEach((name, index) => {
const stats = results[index];
const entry = {
name,
path: filepaths[index],
dirent: utils.fs.createDirentFromStats(name, stats)
};
if (settings.stats) {
entry.stats = stats;
}
entries.push(entry);
});
callSuccessCallback(callback, entries);
});
});
}
exports.readdir = readdir;
function callFailureCallback(callback, error) {
callback(error);
}
function callSuccessCallback(callback, result) {
callback(null, result);
}

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,180 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const sinon = require("sinon");
const fs_macchiato_1 = require("../../../fs.macchiato");
const constants_1 = require("../constants");
const settings_1 = require("../settings");
const provider = require("./async");
const ROOT_PATH = 'root';
const FIRST_FILE_PATH = 'first.txt';
const SECOND_FILE_PATH = 'second.txt';
const FIRST_ENTRY_PATH = path.join(ROOT_PATH, FIRST_FILE_PATH);
const SECOND_ENTRY_PATH = path.join(ROOT_PATH, SECOND_FILE_PATH);
describe('Providers → Async', () => {
describe('.read', () => {
it('should call correct method based on Node.js version', (done) => {
const readdir = sinon.stub();
readdir.yields(null, []);
const settings = new settings_1.default({
fs: { readdir: readdir }
});
provider.read(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries, []);
if (constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
sinon.assert.match(readdir.args, [[ROOT_PATH, { withFileTypes: true }, sinon.match.func]]);
}
else {
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
}
done();
});
});
it('should always use `readdir` method when the `stats` option is enabled', (done) => {
const readdir = sinon.stub();
readdir.yields(null, []);
const settings = new settings_1.default({
fs: { readdir: readdir },
stats: true
});
provider.read(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries, []);
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
done();
});
});
});
describe('.readdirWithFileTypes', () => {
it('should return entries', (done) => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const readdir = sinon.stub();
readdir.yields(null, [dirent]);
const settings = new settings_1.default({
fs: { readdir: readdir }
});
const expected = [
{
dirent,
name: FIRST_FILE_PATH,
path: FIRST_ENTRY_PATH
}
];
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
sinon.assert.match(readdir.args, [[ROOT_PATH, { withFileTypes: true }, sinon.match.func]]);
assert.deepStrictEqual(entries, expected);
done();
});
});
it('should call fs.stat for symbolic link when the "followSymbolicLink" option is enabled', (done) => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const secondDirent = new fs_macchiato_1.Dirent({ name: SECOND_FILE_PATH, isSymbolicLink: true });
const stats = new fs_macchiato_1.Stats();
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent, secondDirent]);
stat.yields(null, stats);
const settings = new settings_1.default({
followSymbolicLinks: true,
fs: {
readdir: readdir,
stat: stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
assert.ok(!entries[1].dirent.isSymbolicLink());
sinon.assert.match(stat.args, [[SECOND_ENTRY_PATH, sinon.match.func]]);
done();
});
});
it('should return lstat for broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is disabled', (done) => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent]);
stat.yields(new Error('error'));
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: false,
fs: {
readdir: readdir,
stat: stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 1);
assert.ok(entries[0].dirent.isSymbolicLink());
done();
});
});
it('should throw an error fro broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is enabled', (done) => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent]);
stat.yields(new Error('error'));
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: true,
fs: {
readdir: readdir,
stat: stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error.message, 'error');
assert.strictEqual(entries, undefined);
done();
});
});
});
describe('.readdir', () => {
it('should return entries', (done) => {
const stats = new fs_macchiato_1.Stats();
const readdir = sinon.stub();
const lstat = sinon.stub();
readdir.yields(null, [FIRST_FILE_PATH]);
lstat.yields(null, stats);
const settings = new settings_1.default({
fs: {
readdir: readdir,
lstat: lstat
}
});
provider.readdir(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
sinon.assert.match(lstat.args, [[FIRST_ENTRY_PATH, sinon.match.func]]);
assert.strictEqual(entries[0].name, FIRST_FILE_PATH);
assert.strictEqual(entries[0].path, FIRST_ENTRY_PATH);
assert.strictEqual(entries[0].dirent.name, FIRST_FILE_PATH);
done();
});
});
it('should return entries with `stats` property', (done) => {
const stats = new fs_macchiato_1.Stats();
const readdir = sinon.stub();
const lstat = sinon.stub();
readdir.yields(null, [FIRST_FILE_PATH]);
lstat.yields(null, stats);
const settings = new settings_1.default({
fs: {
readdir: readdir,
lstat: lstat
},
stats: true
});
provider.readdir(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries[0].stats, stats);
done();
});
});
});
});

View File

@@ -0,0 +1,2 @@
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/providers/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAShF"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.joinPathSegments = void 0;
function joinPathSegments(a, b, separator) {
/**
* 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/providers/common.spec.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const common = require("./common");
describe('Readers → Common', () => {
describe('.joinPathSegments', () => {
it('should return concatenated string', () => {
assert.strictEqual(common.joinPathSegments('.', 'a', '/'), './a');
});
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,6 @@
import Settings from '../settings';
import { Entry } from '../types';
export declare function read(directory: string, settings: Settings): Entry[];
export declare function readdirWithFileTypes(directory: string, settings: Settings): Entry[];
export declare function readdir(directory: string, settings: Settings): 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":"AAGA,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAMnE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAwBnF;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAmBtE"}

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

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readdir = exports.readdirWithFileTypes = exports.read = void 0;
const fsStat = require("@nodelib/fs.stat");
const constants_1 = require("../constants");
const utils = require("../utils");
const common = require("./common");
function read(directory, settings) {
if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
return readdirWithFileTypes(directory, settings);
}
return readdir(directory, settings);
}
exports.read = read;
function readdirWithFileTypes(directory, settings) {
const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
return dirents.map((dirent) => {
const entry = {
dirent,
name: dirent.name,
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
};
if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
try {
const stats = settings.fs.statSync(entry.path);
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
}
catch (error) {
if (settings.throwErrorOnBrokenSymbolicLink) {
throw error;
}
}
}
return entry;
});
}
exports.readdirWithFileTypes = readdirWithFileTypes;
function readdir(directory, settings) {
const names = settings.fs.readdirSync(directory);
return names.map((name) => {
const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
const stats = fsStat.statSync(entryPath, settings.fsStatSettings);
const entry = {
name,
path: entryPath,
dirent: utils.fs.createDirentFromStats(name, stats)
};
if (settings.stats) {
entry.stats = stats;
}
return entry;
});
}
exports.readdir = readdir;

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,144 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
const sinon = require("sinon");
const fs_macchiato_1 = require("../../../fs.macchiato");
const constants_1 = require("../constants");
const settings_1 = require("../settings");
const provider = require("./sync");
const ROOT_PATH = 'root';
const FIRST_FILE_PATH = 'first.txt';
const SECOND_FILE_PATH = 'second.txt';
const FIRST_ENTRY_PATH = path.join(ROOT_PATH, FIRST_FILE_PATH);
const SECOND_ENTRY_PATH = path.join(ROOT_PATH, SECOND_FILE_PATH);
describe('Providers → Sync', () => {
describe('.read', () => {
it('should call correct method based on Node.js version', () => {
const readdirSync = sinon.stub().returns([]);
const settings = new settings_1.default({
fs: { readdirSync: readdirSync }
});
const actual = provider.read(ROOT_PATH, settings);
assert.deepStrictEqual(actual, []);
if (constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH, { withFileTypes: true }]]);
}
else {
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
}
});
it('should always use `readdir` method when the `stats` option is enabled', () => {
const readdirSync = sinon.stub().returns([]);
const settings = new settings_1.default({
fs: { readdirSync: readdirSync },
stats: true
});
provider.read(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
});
});
describe('.readdirWithFileTypes', () => {
it('should return entries', () => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const readdirSync = sinon.stub().returns([dirent]);
const settings = new settings_1.default({
fs: { readdirSync: readdirSync }
});
const expected = [
{
dirent,
name: FIRST_FILE_PATH,
path: FIRST_ENTRY_PATH
}
];
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH, { withFileTypes: true }]]);
assert.deepStrictEqual(actual, expected);
});
it('should call fs.stat for symbolic link when the "followSymbolicLink" option is enabled', () => {
const firstDirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH });
const secondDirent = new fs_macchiato_1.Dirent({ name: SECOND_FILE_PATH, isSymbolicLink: true });
const stats = new fs_macchiato_1.Stats();
const readdirSync = sinon.stub().returns([firstDirent, secondDirent]);
const statSync = sinon.stub().returns(stats);
const settings = new settings_1.default({
followSymbolicLinks: true,
fs: {
readdirSync: readdirSync,
statSync: statSync
}
});
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.strictEqual(actual.length, 2);
assert.deepStrictEqual(statSync.args, [[SECOND_ENTRY_PATH]]);
assert.ok(!actual[1].dirent.isSymbolicLink());
});
it('should return lstat for broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is disabled', () => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdirSync = sinon.stub().returns([dirent]);
const statSync = () => {
throw new Error('error');
};
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: false,
fs: {
readdirSync: readdirSync,
statSync: statSync
}
});
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.strictEqual(actual.length, 1);
});
it('should throw an error fro broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is enabled', () => {
const dirent = new fs_macchiato_1.Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdirSync = sinon.stub().returns([dirent]);
const statSync = () => {
throw new Error('error');
};
const settings = new settings_1.default({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: true,
fs: {
readdirSync: readdirSync,
statSync: statSync
}
});
const expectedErrorMessageRe = /Error: error/;
assert.throws(() => provider.readdirWithFileTypes(ROOT_PATH, settings), expectedErrorMessageRe);
});
});
describe('.readdir', () => {
it('should return entries', () => {
const stats = new fs_macchiato_1.Stats();
const readdirSync = sinon.stub().returns([FIRST_FILE_PATH]);
const lstatSync = sinon.stub().returns(stats);
const settings = new settings_1.default({
fs: {
readdirSync: readdirSync,
lstatSync: lstatSync
}
});
const actual = provider.readdir(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
assert.strictEqual(actual[0].name, FIRST_FILE_PATH);
assert.strictEqual(actual[0].path, FIRST_ENTRY_PATH);
assert.strictEqual(actual[0].dirent.name, FIRST_FILE_PATH);
});
it('should return entries with `stats` property', () => {
const stats = new fs_macchiato_1.Stats();
const readdirSync = sinon.stub().returns([FIRST_FILE_PATH]);
const lstatSync = sinon.stub().returns(stats);
const settings = new settings_1.default({
fs: {
readdirSync: readdirSync,
lstatSync: lstatSync
},
stats: true
});
const actual = provider.readdir(ROOT_PATH, settings);
assert.deepStrictEqual(actual[0].stats, stats);
});
});
});

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

@@ -0,0 +1,21 @@
import * as fsStat from '@nodelib/fs.stat';
import * as fs from './adapters/fs';
export declare type Options = {
followSymbolicLinks?: boolean;
fs?: Partial<fs.FileSystemAdapter>;
pathSegmentSeparator?: string;
stats?: boolean;
throwErrorOnBrokenSymbolicLink?: boolean;
};
export default class Settings {
private readonly _options;
readonly followSymbolicLinks: boolean;
readonly fs: fs.FileSystemAdapter;
readonly pathSegmentSeparator: string;
readonly stats: boolean;
readonly throwErrorOnBrokenSymbolicLink: boolean;
readonly fsStatSettings: fsStat.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,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpC,oBAAY,OAAO,GAAG;IACrB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACnC,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;IAahB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAZrC,SAAgB,mBAAmB,EAAE,OAAO,CAA4D;IACxG,SAAgB,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAgD;IACxF,SAAgB,oBAAoB,EAAE,MAAM,CAAgE;IAC5G,SAAgB,KAAK,EAAE,OAAO,CAA8C;IAC5E,SAAgB,8BAA8B,EAAE,OAAO,CAAsE;IAE7H,SAAgB,cAAc,EAAE,MAAM,CAAC,QAAQ,CAI5C;gBAE0B,QAAQ,GAAE,OAAY;IAEnD,OAAO,CAAC,SAAS;CAGjB"}

24
node_modules/@nodelib/fs.scandir/out/settings.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const fsStat = require("@nodelib/fs.stat");
const fs = require("./adapters/fs");
class Settings {
constructor(_options = {}) {
this._options = _options;
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
this.fs = fs.createFileSystemAdapter(this._options.fs);
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep);
this.stats = this._getValue(this._options.stats, false);
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
this.fsStatSettings = new fsStat.Settings({
followSymbolicLink: this.followSymbolicLinks,
fs: this.fs,
throwErrorOnBrokenSymbolicLink: this.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":""}

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

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert = require("assert");
const path = require("path");
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.followSymbolicLinks);
assert.ok(!settings.stats);
assert.strictEqual(settings.pathSegmentSeparator, path.sep);
assert.ok(settings.fsStatSettings);
assert.ok(settings.throwErrorOnBrokenSymbolicLink);
});
it('should return instance with custom values', () => {
const lstatSync = () => new fs_macchiato_1.Stats();
const settings = new settings_1.default({
fs: fs.createFileSystemAdapter({ lstatSync }),
stats: true
});
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter({ lstatSync }));
assert.ok(settings.stats);
});
});

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

@@ -0,0 +1,20 @@
/// <reference types="node" />
import * as fs from 'fs';
export declare type Entry = {
dirent: Dirent;
name: string;
path: string;
stats?: Stats;
};
export declare type Stats = fs.Stats;
export declare type Dirent = {
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isDirectory(): boolean;
isFIFO(): boolean;
isFile(): boolean;
isSocket(): boolean;
isSymbolicLink(): boolean;
name: 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,EAAE,MAAM,IAAI,CAAC;AAEzB,oBAAY,KAAK,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,oBAAY,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;AAE7B,oBAAY,MAAM,GAAG;IACpB,aAAa,IAAI,OAAO,CAAC;IACzB,iBAAiB,IAAI,OAAO,CAAC;IAC7B,WAAW,IAAI,OAAO,CAAC;IACvB,MAAM,IAAI,OAAO,CAAC;IAClB,MAAM,IAAI,OAAO,CAAC;IAClB,QAAQ,IAAI,OAAO,CAAC;IACpB,cAAc,IAAI,OAAO,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CACb,CAAC"}

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

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

3
node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import { Dirent, Stats } from '../types';
export declare function createDirentFromStats(name: string, stats: Stats): Dirent;
//# sourceMappingURL=fs.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAsBzC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAExE"}

19
node_modules/@nodelib/fs.scandir/out/utils/fs.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDirentFromStats = void 0;
class DirentFromStats {
constructor(name, stats) {
this.name = name;
this.isBlockDevice = stats.isBlockDevice.bind(stats);
this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
this.isDirectory = stats.isDirectory.bind(stats);
this.isFIFO = stats.isFIFO.bind(stats);
this.isFile = stats.isFile.bind(stats);
this.isSocket = stats.isSocket.bind(stats);
this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
}
}
function createDirentFromStats(name, stats) {
return new DirentFromStats(name, stats);
}
exports.createDirentFromStats = createDirentFromStats;

View File

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

View File

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

20
node_modules/@nodelib/fs.scandir/out/utils/fs.spec.js generated vendored Normal file
View 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 util = require("./fs");
describe('Utils → FS', () => {
describe('.createDirentFromStats', () => {
it('should convert fs.Stats to fs.Dirent', () => {
const actual = util.createDirentFromStats('name', new fs_macchiato_1.Stats());
assert.strictEqual(actual.name, 'name');
assert.ok(!actual.isBlockDevice());
assert.ok(!actual.isCharacterDevice());
assert.ok(!actual.isDirectory());
assert.ok(!actual.isFIFO());
assert.ok(actual.isFile());
assert.ok(!actual.isSocket());
assert.ok(!actual.isSymbolicLink());
});
});
});

View File

@@ -0,0 +1,3 @@
import * as fs from './fs';
export { fs };
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,MAAM,CAAC;AAE3B,OAAO,EACN,EAAE,EACF,CAAC"}

5
node_modules/@nodelib/fs.scandir/out/utils/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fs = void 0;
const fs = require("./fs");
exports.fs = fs;

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

@@ -0,0 +1,67 @@
{
"_args": [
[
"@nodelib/fs.scandir@2.1.4",
"/workspaces/upload-google-play"
]
],
"_from": "@nodelib/fs.scandir@2.1.4",
"_id": "@nodelib/fs.scandir@2.1.4",
"_inBundle": false,
"_integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==",
"_location": "/@nodelib/fs.scandir",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nodelib/fs.scandir@2.1.4",
"name": "@nodelib/fs.scandir",
"escapedName": "@nodelib%2ffs.scandir",
"scope": "@nodelib",
"rawSpec": "2.1.4",
"saveSpec": null,
"fetchSpec": "2.1.4"
},
"_requiredBy": [
"/@nodelib/fs.walk"
],
"_resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz",
"_spec": "2.1.4",
"_where": "/workspaces/upload-google-play",
"dependencies": {
"@nodelib/fs.stat": "2.0.4",
"run-parallel": "^1.1.9"
},
"description": "List files and directories inside the specified directory",
"engines": {
"node": ">= 8"
},
"gitHead": "cb5f7e893a986164c3b847a4f1faef6c54cadd68",
"keywords": [
"NodeLib",
"fs",
"FileSystem",
"file system",
"scandir",
"readdir",
"dirent"
],
"license": "MIT",
"main": "out/index.js",
"name": "@nodelib/fs.scandir",
"repository": {
"type": "git",
"url": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir"
},
"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.1.4"
}

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

30
node_modules/@nodelib/fs.scandir/src/adapters/fs.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import * as fs from 'fs';
export type FileSystemAdapter = {
lstat: typeof fs.lstat;
stat: typeof fs.stat;
lstatSync: typeof fs.lstatSync;
statSync: typeof fs.statSync;
readdir: typeof fs.readdir;
readdirSync: typeof fs.readdirSync;
};
export const FILE_SYSTEM_ADAPTER: FileSystemAdapter = {
lstat: fs.lstat,
stat: fs.stat,
lstatSync: fs.lstatSync,
statSync: fs.statSync,
readdir: fs.readdir,
readdirSync: fs.readdirSync
};
export function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter {
if (fsMethods === undefined) {
return FILE_SYSTEM_ADAPTER;
}
return {
...FILE_SYSTEM_ADAPTER,
...fsMethods
};
}

15
node_modules/@nodelib/fs.scandir/src/constants.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.');
const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10);
const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10);
const SUPPORTED_MAJOR_VERSION = 10;
const SUPPORTED_MINOR_VERSION = 10;
const IS_MATCHED_BY_MAJOR = MAJOR_VERSION > SUPPORTED_MAJOR_VERSION;
const IS_MATCHED_BY_MAJOR_AND_MINOR = MAJOR_VERSION === SUPPORTED_MAJOR_VERSION && MINOR_VERSION >= SUPPORTED_MINOR_VERSION;
/**
* IS `true` for Node.js 10.10 and greater.
*/
export const IS_SUPPORT_READDIR_WITH_FILE_TYPES = IS_MATCHED_BY_MAJOR || IS_MATCHED_BY_MAJOR_AND_MINOR;

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

@@ -0,0 +1,85 @@
import * as assert from 'assert';
import * as fs from 'fs';
import * as rimraf from 'rimraf';
import { scandir, scandirSync, Settings } from '.';
describe('Package', () => {
before(() => {
rimraf.sync('fixtures');
fs.mkdirSync('fixtures');
fs.writeFileSync('fixtures/file.txt', '');
});
after(() => {
rimraf.sync('fixtures');
});
describe('.scandir', () => {
it('should work without options or settings', (done) => {
scandir('fixtures', (error, entries) => {
assert.strictEqual(error, null);
assert.ok(entries[0].name);
assert.ok(entries[0].path);
assert.ok(entries[0].dirent);
done();
});
});
it('should work with options', (done) => {
scandir('fixtures', { stats: true }, (error, entries) => {
assert.strictEqual(error, null);
assert.ok(entries[0].name);
assert.ok(entries[0].path);
assert.ok(entries[0].dirent);
assert.ok(entries[0].stats);
done();
});
});
it('should work with settings', (done) => {
const settings = new Settings({ stats: true });
scandir('fixtures', settings, (error, entries) => {
assert.strictEqual(error, null);
assert.ok(entries[0].name);
assert.ok(entries[0].path);
assert.ok(entries[0].dirent);
assert.ok(entries[0].stats);
done();
});
});
});
describe('.scandirSync', () => {
it('should work without options or settings', () => {
const actual = scandirSync('fixtures');
assert.ok(actual[0].name);
assert.ok(actual[0].path);
assert.ok(actual[0].dirent);
});
it('should work with options', () => {
const actual = scandirSync('fixtures', { stats: true });
assert.ok(actual[0].name);
assert.ok(actual[0].path);
assert.ok(actual[0].dirent);
assert.ok(actual[0].stats);
});
it('should work with settings', () => {
const settings = new Settings({ stats: true });
const actual = scandirSync('fixtures', settings);
assert.ok(actual[0].name);
assert.ok(actual[0].path);
assert.ok(actual[0].dirent);
assert.ok(actual[0].stats);
});
});
});

51
node_modules/@nodelib/fs.scandir/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,51 @@
import { FileSystemAdapter } from './adapters/fs';
import * as async from './providers/async';
import * as sync from './providers/sync';
import Settings, { Options } from './settings';
import { Dirent, Entry } from './types';
type AsyncCallback = async.AsyncCallback;
function scandir(path: string, callback: AsyncCallback): void;
function scandir(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
function scandir(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 scandir {
function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
}
function scandirSync(path: string, optionsOrSettings?: Options | Settings): Entry[] {
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 {
scandir,
scandirSync,
Settings,
// https://github.com/typescript-eslint/typescript-eslint/issues/131
// eslint-disable-next-line no-undef
AsyncCallback,
Dirent,
Entry,
FileSystemAdapter,
Options
};

View File

@@ -0,0 +1,236 @@
import * as assert from 'assert';
import * as fs from 'fs';
import * as path from 'path';
import * as sinon from 'sinon';
import { Dirent, Stats } from '../../../fs.macchiato';
import { IS_SUPPORT_READDIR_WITH_FILE_TYPES } from '../constants';
import Settings from '../settings';
import { Entry } from '../types';
import * as provider from './async';
const ROOT_PATH = 'root';
const FIRST_FILE_PATH = 'first.txt';
const SECOND_FILE_PATH = 'second.txt';
const FIRST_ENTRY_PATH = path.join(ROOT_PATH, FIRST_FILE_PATH);
const SECOND_ENTRY_PATH = path.join(ROOT_PATH, SECOND_FILE_PATH);
describe('Providers → Async', () => {
describe('.read', () => {
it('should call correct method based on Node.js version', (done) => {
const readdir = sinon.stub();
readdir.yields(null, []);
const settings = new Settings({
fs: { readdir: readdir as unknown as typeof fs.readdir }
});
provider.read(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries, []);
if (IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
sinon.assert.match(readdir.args, [[ROOT_PATH, { withFileTypes: true }, sinon.match.func]]);
} else {
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
}
done();
});
});
it('should always use `readdir` method when the `stats` option is enabled', (done) => {
const readdir = sinon.stub();
readdir.yields(null, []);
const settings = new Settings({
fs: { readdir: readdir as unknown as typeof fs.readdir },
stats: true
});
provider.read(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries, []);
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
done();
});
});
});
describe('.readdirWithFileTypes', () => {
it('should return entries', (done) => {
const dirent = new Dirent({ name: FIRST_FILE_PATH });
const readdir = sinon.stub();
readdir.yields(null, [dirent]);
const settings = new Settings({
fs: { readdir: readdir as unknown as typeof fs.readdir }
});
const expected: Entry[] = [
{
dirent,
name: FIRST_FILE_PATH,
path: FIRST_ENTRY_PATH
}
];
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
sinon.assert.match(readdir.args, [[ROOT_PATH, { withFileTypes: true }, sinon.match.func]]);
assert.deepStrictEqual(entries, expected);
done();
});
});
it('should call fs.stat for symbolic link when the "followSymbolicLink" option is enabled', (done) => {
const firstDirent = new Dirent({ name: FIRST_FILE_PATH });
const secondDirent = new Dirent({ name: SECOND_FILE_PATH, isSymbolicLink: true });
const stats = new Stats();
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent, secondDirent]);
stat.yields(null, stats);
const settings = new Settings({
followSymbolicLinks: true,
fs: {
readdir: readdir as unknown as typeof fs.readdir,
stat: stat as unknown as typeof fs.stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 2);
assert.ok(!entries[1].dirent.isSymbolicLink());
sinon.assert.match(stat.args, [[SECOND_ENTRY_PATH, sinon.match.func]]);
done();
});
});
it('should return lstat for broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is disabled', (done) => {
const firstDirent = new Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent]);
stat.yields(new Error('error'));
const settings = new Settings({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: false,
fs: {
readdir: readdir as unknown as typeof fs.readdir,
stat: stat as unknown as typeof fs.stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.strictEqual(entries.length, 1);
assert.ok(entries[0].dirent.isSymbolicLink());
done();
});
});
it('should throw an error fro broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is enabled', (done) => {
const firstDirent = new Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdir = sinon.stub();
const stat = sinon.stub();
readdir.yields(null, [firstDirent]);
stat.yields(new Error('error'));
const settings = new Settings({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: true,
fs: {
readdir: readdir as unknown as typeof fs.readdir,
stat: stat as unknown as typeof fs.stat
}
});
provider.readdirWithFileTypes(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error.message, 'error');
assert.strictEqual(entries, undefined);
done();
});
});
});
describe('.readdir', () => {
it('should return entries', (done) => {
const stats = new Stats();
const readdir = sinon.stub();
const lstat = sinon.stub();
readdir.yields(null, [FIRST_FILE_PATH]);
lstat.yields(null, stats);
const settings = new Settings({
fs: {
readdir: readdir as unknown as typeof fs.readdir,
lstat: lstat as unknown as typeof fs.lstat
}
});
provider.readdir(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
sinon.assert.match(readdir.args, [[ROOT_PATH, sinon.match.func]]);
sinon.assert.match(lstat.args, [[FIRST_ENTRY_PATH, sinon.match.func]]);
assert.strictEqual(entries[0].name, FIRST_FILE_PATH);
assert.strictEqual(entries[0].path, FIRST_ENTRY_PATH);
assert.strictEqual(entries[0].dirent.name, FIRST_FILE_PATH);
done();
});
});
it('should return entries with `stats` property', (done) => {
const stats = new Stats();
const readdir = sinon.stub();
const lstat = sinon.stub();
readdir.yields(null, [FIRST_FILE_PATH]);
lstat.yields(null, stats);
const settings = new Settings({
fs: {
readdir: readdir as unknown as typeof fs.readdir,
lstat: lstat as unknown as typeof fs.lstat
},
stats: true
});
provider.readdir(ROOT_PATH, settings, (error, entries) => {
assert.strictEqual(error, null);
assert.deepStrictEqual(entries[0].stats, stats);
done();
});
});
});
});

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

@@ -0,0 +1,121 @@
import * as fsStat from '@nodelib/fs.stat';
import * as rpl from 'run-parallel';
import { IS_SUPPORT_READDIR_WITH_FILE_TYPES } from '../constants';
import Settings from '../settings';
import { Entry, Stats } from '../types';
import * as utils from '../utils';
import * as common from './common';
type RplTaskStats = rpl.Task<Stats>;
type RplTaskEntry = rpl.Task<Entry>;
type FailureCallback = (err: NodeJS.ErrnoException) => void;
type SuccessCallback = (err: null, entries: Entry[]) => void;
export type AsyncCallback = (err: NodeJS.ErrnoException, entries: Entry[]) => void;
export function read(directory: string, settings: Settings, callback: AsyncCallback): void {
if (!settings.stats && IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
return readdirWithFileTypes(directory, settings, callback);
}
return readdir(directory, settings, callback);
}
export function readdirWithFileTypes(directory: string, settings: Settings, callback: AsyncCallback): void {
settings.fs.readdir(directory, { withFileTypes: true }, (readdirError, dirents) => {
if (readdirError !== null) {
return callFailureCallback(callback, readdirError);
}
const entries: Entry[] = dirents.map((dirent) => ({
dirent,
name: dirent.name,
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
}));
if (!settings.followSymbolicLinks) {
return callSuccessCallback(callback, entries);
}
const tasks: RplTaskEntry[] = entries.map((entry) => makeRplTaskEntry(entry, settings));
rpl(tasks, (rplError: Error | null, rplEntries) => {
if (rplError !== null) {
return callFailureCallback(callback, rplError);
}
callSuccessCallback(callback, rplEntries);
});
});
}
function makeRplTaskEntry(entry: Entry, settings: Settings): RplTaskEntry {
return (done) => {
if (!entry.dirent.isSymbolicLink()) {
return done(null, entry);
}
settings.fs.stat(entry.path, (statError, stats) => {
if (statError !== null) {
if (settings.throwErrorOnBrokenSymbolicLink) {
return done(statError);
}
return done(null, entry);
}
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
return done(null, entry);
});
};
}
export function readdir(directory: string, settings: Settings, callback: AsyncCallback): void {
settings.fs.readdir(directory, (readdirError, names) => {
if (readdirError !== null) {
return callFailureCallback(callback, readdirError);
}
const filepaths = names.map((name) => common.joinPathSegments(directory, name, settings.pathSegmentSeparator));
const tasks: RplTaskStats[] = filepaths.map((filepath): RplTaskStats => {
return (done) => fsStat.stat(filepath, settings.fsStatSettings, done);
});
rpl(tasks, (rplError: Error | null, results) => {
if (rplError !== null) {
return callFailureCallback(callback, rplError);
}
const entries: Entry[] = [];
names.forEach((name, index) => {
const stats = results[index];
const entry: Entry = {
name,
path: filepaths[index],
dirent: utils.fs.createDirentFromStats(name, stats)
};
if (settings.stats) {
entry.stats = stats;
}
entries.push(entry);
});
callSuccessCallback(callback, entries);
});
});
}
function callFailureCallback(callback: AsyncCallback, error: NodeJS.ErrnoException): void {
(callback as FailureCallback)(error);
}
function callSuccessCallback(callback: AsyncCallback, result: Entry[]): void {
(callback as unknown as SuccessCallback)(null, result);
}

View File

@@ -0,0 +1,24 @@
import * as assert from 'assert';
import * as common from './common';
describe('Readers → Common', () => {
describe('.joinPathSegments', () => {
it('should return concatenated string', () => {
assert.strictEqual(common.joinPathSegments('.', 'a', '/'), './a');
});
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,10 @@
export function joinPathSegments(a: string, b: string, separator: string): string {
/**
* The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
*/
if (a.endsWith(separator)) {
return a + b;
}
return a + separator + b;
}

View File

@@ -0,0 +1,186 @@
import * as assert from 'assert';
import * as fs from 'fs';
import * as path from 'path';
import * as sinon from 'sinon';
import { Dirent, Stats } from '../../../fs.macchiato';
import { IS_SUPPORT_READDIR_WITH_FILE_TYPES } from '../constants';
import Settings from '../settings';
import { Entry } from '../types';
import * as provider from './sync';
const ROOT_PATH = 'root';
const FIRST_FILE_PATH = 'first.txt';
const SECOND_FILE_PATH = 'second.txt';
const FIRST_ENTRY_PATH = path.join(ROOT_PATH, FIRST_FILE_PATH);
const SECOND_ENTRY_PATH = path.join(ROOT_PATH, SECOND_FILE_PATH);
describe('Providers → Sync', () => {
describe('.read', () => {
it('should call correct method based on Node.js version', () => {
const readdirSync = sinon.stub().returns([]);
const settings = new Settings({
fs: { readdirSync: readdirSync as unknown as typeof fs.readdirSync }
});
const actual = provider.read(ROOT_PATH, settings);
assert.deepStrictEqual(actual, []);
if (IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH, { withFileTypes: true }]]);
} else {
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
}
});
it('should always use `readdir` method when the `stats` option is enabled', () => {
const readdirSync = sinon.stub().returns([]);
const settings = new Settings({
fs: { readdirSync: readdirSync as unknown as typeof fs.readdirSync },
stats: true
});
provider.read(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
});
});
describe('.readdirWithFileTypes', () => {
it('should return entries', () => {
const dirent = new Dirent({ name: FIRST_FILE_PATH });
const readdirSync = sinon.stub().returns([dirent]);
const settings = new Settings({
fs: { readdirSync: readdirSync as unknown as typeof fs.readdirSync }
});
const expected: Entry[] = [
{
dirent,
name: FIRST_FILE_PATH,
path: FIRST_ENTRY_PATH
}
];
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH, { withFileTypes: true }]]);
assert.deepStrictEqual(actual, expected);
});
it('should call fs.stat for symbolic link when the "followSymbolicLink" option is enabled', () => {
const firstDirent = new Dirent({ name: FIRST_FILE_PATH });
const secondDirent = new Dirent({ name: SECOND_FILE_PATH, isSymbolicLink: true });
const stats = new Stats();
const readdirSync = sinon.stub().returns([firstDirent, secondDirent]);
const statSync = sinon.stub().returns(stats);
const settings = new Settings({
followSymbolicLinks: true,
fs: {
readdirSync: readdirSync as unknown as typeof fs.readdirSync,
statSync: statSync as unknown as typeof fs.statSync
}
});
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.strictEqual(actual.length, 2);
assert.deepStrictEqual(statSync.args, [[SECOND_ENTRY_PATH]]);
assert.ok(!actual[1].dirent.isSymbolicLink());
});
it('should return lstat for broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is disabled', () => {
const dirent = new Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdirSync = sinon.stub().returns([dirent]);
const statSync = (): never => {
throw new Error('error');
};
const settings = new Settings({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: false,
fs: {
readdirSync: readdirSync as unknown as typeof fs.readdirSync,
statSync: statSync as unknown as typeof fs.statSync
}
});
const actual = provider.readdirWithFileTypes(ROOT_PATH, settings);
assert.strictEqual(actual.length, 1);
});
it('should throw an error fro broken symbolic link when the "throwErrorOnBrokenSymbolicLink" option is enabled', () => {
const dirent = new Dirent({ name: FIRST_FILE_PATH, isSymbolicLink: true });
const readdirSync = sinon.stub().returns([dirent]);
const statSync = (): never => {
throw new Error('error');
};
const settings = new Settings({
followSymbolicLinks: true,
throwErrorOnBrokenSymbolicLink: true,
fs: {
readdirSync: readdirSync as unknown as typeof fs.readdirSync,
statSync: statSync as unknown as typeof fs.statSync
}
});
const expectedErrorMessageRe = /Error: error/;
assert.throws(() => provider.readdirWithFileTypes(ROOT_PATH, settings), expectedErrorMessageRe);
});
});
describe('.readdir', () => {
it('should return entries', () => {
const stats = new Stats();
const readdirSync = sinon.stub().returns([FIRST_FILE_PATH]);
const lstatSync = sinon.stub().returns(stats);
const settings = new Settings({
fs: {
readdirSync: readdirSync as unknown as typeof fs.readdirSync,
lstatSync: lstatSync as unknown as typeof fs.lstatSync
}
});
const actual = provider.readdir(ROOT_PATH, settings);
assert.deepStrictEqual(readdirSync.args, [[ROOT_PATH]]);
assert.strictEqual(actual[0].name, FIRST_FILE_PATH);
assert.strictEqual(actual[0].path, FIRST_ENTRY_PATH);
assert.strictEqual(actual[0].dirent.name, FIRST_FILE_PATH);
});
it('should return entries with `stats` property', () => {
const stats = new Stats();
const readdirSync = sinon.stub().returns([FIRST_FILE_PATH]);
const lstatSync = sinon.stub().returns(stats);
const settings = new Settings({
fs: {
readdirSync: readdirSync as unknown as typeof fs.readdirSync,
lstatSync: lstatSync as unknown as typeof fs.lstatSync
},
stats: true
});
const actual = provider.readdir(ROOT_PATH, settings);
assert.deepStrictEqual(actual[0].stats, stats);
});
});
});

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

@@ -0,0 +1,62 @@
import * as fsStat from '@nodelib/fs.stat';
import { IS_SUPPORT_READDIR_WITH_FILE_TYPES } from '../constants';
import Settings from '../settings';
import { Entry } from '../types';
import * as utils from '../utils';
import * as common from './common';
export function read(directory: string, settings: Settings): Entry[] {
if (!settings.stats && IS_SUPPORT_READDIR_WITH_FILE_TYPES) {
return readdirWithFileTypes(directory, settings);
}
return readdir(directory, settings);
}
export function readdirWithFileTypes(directory: string, settings: Settings): Entry[] {
const dirents = settings.fs.readdirSync(directory, { withFileTypes: true });
return dirents.map((dirent) => {
const entry: Entry = {
dirent,
name: dirent.name,
path: common.joinPathSegments(directory, dirent.name, settings.pathSegmentSeparator)
};
if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) {
try {
const stats = settings.fs.statSync(entry.path);
entry.dirent = utils.fs.createDirentFromStats(entry.name, stats);
} catch (error) {
if (settings.throwErrorOnBrokenSymbolicLink) {
throw error;
}
}
}
return entry;
});
}
export function readdir(directory: string, settings: Settings): Entry[] {
const names = settings.fs.readdirSync(directory);
return names.map((name) => {
const entryPath = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
const stats = fsStat.statSync(entryPath, settings.fsStatSettings);
const entry: Entry = {
name,
path: entryPath,
dirent: utils.fs.createDirentFromStats(name, stats)
};
if (settings.stats) {
entry.stats = stats;
}
return entry;
});
}

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

@@ -0,0 +1,32 @@
import * as assert from 'assert';
import * as path from 'path';
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.followSymbolicLinks);
assert.ok(!settings.stats);
assert.strictEqual(settings.pathSegmentSeparator, path.sep);
assert.ok(settings.fsStatSettings);
assert.ok(settings.throwErrorOnBrokenSymbolicLink);
});
it('should return instance with custom values', () => {
const lstatSync = (): Stats => new Stats();
const settings = new Settings({
fs: fs.createFileSystemAdapter({ lstatSync }),
stats: true
});
assert.deepStrictEqual(settings.fs, fs.createFileSystemAdapter({ lstatSync }));
assert.ok(settings.stats);
});
});

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

@@ -0,0 +1,33 @@
import * as path from 'path';
import * as fsStat from '@nodelib/fs.stat';
import * as fs from './adapters/fs';
export type Options = {
followSymbolicLinks?: boolean;
fs?: Partial<fs.FileSystemAdapter>;
pathSegmentSeparator?: string;
stats?: boolean;
throwErrorOnBrokenSymbolicLink?: boolean;
};
export default class Settings {
public readonly followSymbolicLinks: boolean = this._getValue(this._options.followSymbolicLinks, false);
public readonly fs: fs.FileSystemAdapter = fs.createFileSystemAdapter(this._options.fs);
public readonly pathSegmentSeparator: string = this._getValue(this._options.pathSegmentSeparator, path.sep);
public readonly stats: boolean = this._getValue(this._options.stats, false);
public readonly throwErrorOnBrokenSymbolicLink: boolean = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
public readonly fsStatSettings: fsStat.Settings = new fsStat.Settings({
followSymbolicLink: this.followSymbolicLinks,
fs: this.fs,
throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink
});
constructor(private readonly _options: Options = {}) { }
private _getValue<T>(option: T | undefined, value: T): T {
return option ?? value;
}
}

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

@@ -0,0 +1,21 @@
import * as fs from 'fs';
export type Entry = {
dirent: Dirent;
name: string;
path: string;
stats?: Stats;
};
export type Stats = fs.Stats;
export type Dirent = {
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isDirectory(): boolean;
isFIFO(): boolean;
isFile(): boolean;
isSocket(): boolean;
isSymbolicLink(): boolean;
name: string;
};

21
node_modules/@nodelib/fs.scandir/src/utils/fs.spec.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import * as assert from 'assert';
import { Stats } from '../../../fs.macchiato';
import * as util from './fs';
describe('Utils → FS', () => {
describe('.createDirentFromStats', () => {
it('should convert fs.Stats to fs.Dirent', () => {
const actual = util.createDirentFromStats('name', new Stats());
assert.strictEqual(actual.name, 'name');
assert.ok(!actual.isBlockDevice());
assert.ok(!actual.isCharacterDevice());
assert.ok(!actual.isDirectory());
assert.ok(!actual.isFIFO());
assert.ok(actual.isFile());
assert.ok(!actual.isSocket());
assert.ok(!actual.isSymbolicLink());
});
});
});

27
node_modules/@nodelib/fs.scandir/src/utils/fs.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import * as fs from 'fs';
import { Dirent, Stats } from '../types';
class DirentFromStats implements fs.Dirent {
public isBlockDevice: Stats['isBlockDevice'];
public isCharacterDevice: Stats['isCharacterDevice'];
public isDirectory: Stats['isDirectory'];
public isFIFO: Stats['isFIFO'];
public isFile: Stats['isFile'];
public isSocket: Stats['isSocket'];
public isSymbolicLink: Stats['isSymbolicLink'];
constructor(public name: string, stats: Stats) {
this.isBlockDevice = stats.isBlockDevice.bind(stats);
this.isCharacterDevice = stats.isCharacterDevice.bind(stats);
this.isDirectory = stats.isDirectory.bind(stats);
this.isFIFO = stats.isFIFO.bind(stats);
this.isFile = stats.isFile.bind(stats);
this.isSocket = stats.isSocket.bind(stats);
this.isSymbolicLink = stats.isSymbolicLink.bind(stats);
}
}
export function createDirentFromStats(name: string, stats: Stats): Dirent {
return new DirentFromStats(name, stats);
}

5
node_modules/@nodelib/fs.scandir/src/utils/index.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import * as fs from './fs';
export {
fs
};

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

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

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

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

126
node_modules/@nodelib/fs.stat/README.md generated vendored Normal file
View 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
View 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

View 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
View 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;

View File

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

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

56
node_modules/@nodelib/fs.stat/out/index.spec.js generated vendored Normal file
View 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);
});
});
});

View 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

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

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

View 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

View 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
View 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;

Some files were not shown because too many files have changed in this diff Show More