commit node_modules

This commit is contained in:
Bret Comnes
2020-02-10 12:50:13 -07:00
parent eb6412a365
commit 13eab06cd3
610 changed files with 203178 additions and 60 deletions

View File

@@ -0,0 +1,25 @@
name: tests
on: [push]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [12]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: npm install && npm test
run: |
npm i
npm test
env:
CI: true

22
node_modules/async-folder-walker/.vscode/launch.json generated vendored Normal file
View File

@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
}
]
}

19
node_modules/async-folder-walker/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,19 @@
# async-folder-walker Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
## 2.0.1 - 2019-12-27
* Internal tweaks
* Docs updates
## 2.0.0 - 2019-12-26
* Remove ESM support. Fuggit. It simply offers zero benafits in a node env.
## 1.0.0 - 2019-11-11
* Initial release.

4
node_modules/async-folder-walker/CODE_OF_CONDUCT.md generated vendored Normal file
View File

@@ -0,0 +1,4 @@
# Code of conduct
- This repo is governed as a dictatorship starting with the originator of the project.
- No malevolence tolerated whatsoever.

11
node_modules/async-folder-walker/CONTRIBUTING.md generated vendored Normal file
View File

@@ -0,0 +1,11 @@
# Contributing
- Contributors reserve the right to walk away from this project at any moment with or without notice.
- Questions are welcome, however unless there is a official support contract established between the maintainers and the requester, support is not guaranteed.
- Patches, ideas and changes welcome.
- Fixes almost always welcome.
- Features sometimes welcome. Please open an issue to discuss the issue prior to spending lots of time on the problem. It may be rejected. If you don't want to wait around for the discussion to commence, and you really want to jump into the implementation work, be prepared for fork if the idea is respectfully declined.
- Try to stay within the style of the existing code.
- All tests must pass.
- Additional features or code paths must be tested.
- Aim for 100% coverage.

21
node_modules/async-folder-walker/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 Bret Comnes
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.

170
node_modules/async-folder-walker/README.md generated vendored Normal file
View File

@@ -0,0 +1,170 @@
# async-folder-walker
[![Actions Status](https://github.com/bcomnes/async-folder-walker/workflows/tests/badge.svg)](https://github.com/bcomnes/async-folder-walker/actions)
A recursive async iterator of the files and directories in a given folder. Can take multiple folders, limit walk depth and filter based on path names and stat results.
![](https://repository-images.githubusercontent.com/223294839/43cf9600-0d3f-11ea-858e-81b08a14509f)
```
npm install async-folder-walker
```
## Usage
``` js
const { asyncFolderWalker, allFiles } = require('async-folder-walker')
async function iterateFiles () {
const walker = asyncFolderWalker(['.git', 'node_modules'])
for await (const file of walker) {
console.log(file) // logs the file path!
}
}
async function getAllFiles () {
const allFilepaths = await allFiles(['.git', 'node_modules'])
console.log(allFilepaths)
}
iterateFiles().then(() => getAllFiles())
```
## API
### `const { asyncFolderWalker, allFiles } = require('async-folder-walker')`
Import `asyncFolderWalker` or `allFiles`.
### `async-gen = asyncFolderWalker(paths, [opts])`
Return an async generator that will iterate over all of files inside of a directory. `paths` can be a string path or an Array of string paths.
You can iterate over each file and directory individually using a `for-await...of` loop. Note, you must be inside an [async function statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
```js
const { asyncFolderWalker } = require('async-folder-walker');
async function iterateFiles () {
const walker = asyncFolderWalker(['.git', 'node_modules']);
for await (const file of walker) {
console.log(file); // logs the file path!
}
}
iterateFiles();
```
Opts include:
```js
{
fs: require('fs'),
pathFilter: filepath => true,
statFilter st => true,
maxDepth: Infinity,
shaper: ({ root, filepath, stat, relname, basename }) => filepath
}
```
The `pathFilter` function allows you to filter files from additional async stat operations. Return false to filter the file.
```js
{ // exclude node_modules
pathFilter: filepath => !filepath.includes(node_modules)
}
```
The `statFilter` function allows you to filter files based on the internal stat operation. Return false to filter the file.
```js
{ // exclude all directories:
statFilter: st => !st.isDirectory()
}
```
The `shaper` function lets you change the shape of the returned value based on data accumulaed during the iteration. To return the same shape as [okdistribute/folder-walker](https://github.com/okdistribute/folder-walker) use the following function:
```js
{ // Return the same shape as folder-walker
shaper: fwData => fwData
}
````
Example of a fwData object for a directory:
```js
{
root: '/Users/bret/repos/async-folder-walker/fixtures',
filepath: '/Users/bret/repos/async-folder-walker/fixtures/sub-folder/sub-sub-folder',
stat: Stats {
dev: 16777220,
mode: 16877,
nlink: 3,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 30244023,
size: 96,
blocks: 0,
atimeMs: 1574381262779.8396,
mtimeMs: 1574380914743.5474,
ctimeMs: 1574380914743.5474,
birthtimeMs: 1574380905232.5996,
atime: 2019-11-22T00:07:42.780Z,
mtime: 2019-11-22T00:01:54.744Z,
ctime: 2019-11-22T00:01:54.744Z,
birthtime: 2019-11-22T00:01:45.233Z
},
relname: 'sub-folder/sub-sub-folder',
basename: 'sub-sub-folder'
}
```
and another example for a file on windows:
```js
{
root: 'D:\\a\\async-folder-walker\\async-folder-walker\\fixtures',
filepath: 'D:\\a\\async-folder-walker\\async-folder-walker\\fixtures\\sub-folder\\sub-sub-folder\\sub-sub-folder-file.json',
stat: Stats {
dev: 1321874112,
mode: 33206,
nlink: 1,
uid: 0,
gid: 0,
rdev: 0,
blksize: 4096,
ino: 562949953421580,
size: 37,
blocks: 0,
atimeMs: 1577476819530.035,
mtimeMs: 1577476819530.035,
ctimeMs: 1577476819530.035,
birthtimeMs: 1577476819530.035,
atime: 2019-12-27T20:00:19.530Z,
mtime: 2019-12-27T20:00:19.530Z,
ctime: 2019-12-27T20:00:19.530Z,
birthtime: 2019-12-27T20:00:19.530Z
},
relname: 'sub-folder\\sub-sub-folder\\sub-sub-folder-file.json',
basename: 'sub-sub-folder-file.json'
}
```
The `stat` property is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats) so it has extra methods not listed here.
### `files = await allFiles(paths, [opts])`
Get an Array of all files inside of a directory. `paths` can be a single string path or an array of string paths.
`opts` Is the same as `asyncFolderWalker`.
## See also
This module is effectivly a rewrite of [okdistribute/folder-walker](https://github.com/okdistribute/folder-walker) using async generators instead of Node streams, and a few tweaks to the underlying options to make the results a bit more flexible.
- [for-await...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
## License
MIT

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,3 @@
{
"sub-folder": "content"
}

View File

@@ -0,0 +1,3 @@
{
"sub-sub-folder": "content"
}

3
node_modules/async-folder-walker/fixtures/test.json generated vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"hello": "world"
}

179
node_modules/async-folder-walker/index.js generated vendored Normal file
View File

@@ -0,0 +1,179 @@
const fs = require('fs')
const path = require('path')
const { readdir, lstat } = fs.promises
/**
* pathFilter lets you filter files based on a resolved `filepath`.
* @callback pathFilter
* @param {String} filepath - The resolved `filepath` of the file to test for filtering.
*
* @return {Boolean} Return false to filter the given `filepath` and true to include it.
*/
const pathFilter = filepath => true
/**
* statFilter lets you filter files based on a lstat object.
* @callback statFilter
* @param {Object} st - A fs.Stats instance.
*
* @return {Boolean} Return false to filter the given `filepath` and true to include it.
*/
const statFilter = filepath => true
/**
* FWStats is the object that the okdistribute/folder-walker module returns by default.
*
* @typedef FWStats
* @property {String} root - The filepath of the directory where the walk started.
* @property {String} filepath - The resolved filepath.
* @property {Object} stat - A fs.Stats instance.
* @property {String} relname - The relative path to `root`.
* @property {String} basename - The resolved filepath of the files containing directory.
*/
/**
* shaper lets you change the shape of the returned file data from walk-time stats.
* @callback shaper
* @param {FWStats} fwStats - The same status object returned from folder-walker.
*
* @return {*} - Whatever you want returned from the directory walk.
*/
const shaper = ({ root, filepath, stat, relname, basename }) => filepath
/**
* Options object
*
* @typedef Opts
* @property {pathFilter} [pathFilter] - A pathFilter cb.
* @property {statFilter} [statFilter] - A statFilter cb.
* @property {Number} [maxDepth=Infinity] - The maximum number of folders to walk down into.
* @property {shaper} [shaper] - A shaper cb.
*/
/**
* Create an async generator that iterates over all folders and directories inside of `dirs`.
*
* @async
* @generator
* @function
* @public
* @param {String|String[]} dirs - The path of the directory to walk, or an array of directory paths.
* @param {?(Opts)} opts - Options used for the directory walk.
*
* @yields {Promise<String|any>} - An async iterator that returns anything.
*/
async function * asyncFolderWalker (dirs, opts) {
opts = Object.assign({
fs,
pathFilter,
statFilter,
maxDepth: Infinity,
shaper
}, opts)
const roots = [dirs].flat().filter(opts.pathFilter)
const pending = []
while (roots.length) {
const root = roots.shift()
pending.push(root)
while (pending.length) {
const current = pending.shift()
if (typeof current === 'undefined') continue
const st = await lstat(current)
if ((!st.isDirectory() || depthLimiter(current, root, opts.maxDepth)) && opts.statFilter(st)) {
yield opts.shaper(fwShape(root, current, st))
continue
}
const files = await readdir(current)
files.sort()
for (const file of files) {
var next = path.join(current, file)
if (opts.pathFilter(next)) pending.unshift(next)
}
if (current === root || !opts.statFilter(st)) continue
else yield opts.shaper(fwShape(root, current, st))
}
}
}
/**
* Generates the same shape as the folder-walker module.
*
* @function
* @private
* @param {String} root - Root filepath.
* @param {String} name - Target filepath.
* @param {Object} st - fs.Stat object.
*
* @return {FWStats} - Folder walker object.
*/
function fwShape (root, name, st) {
return {
root: root,
filepath: name,
stat: st,
relname: root === name ? path.basename(name) : path.relative(root, name),
basename: path.basename(name)
}
}
/**
* Test if we are at maximum directory depth.
*
* @private
* @function
* @param {String} filePath - The resolved path of the target fille.
* @param {String} relativeTo - The root directory of the current walk.
* @param {Number} maxDepth - The maximum number of folders to descend into.
*
* @returns {Boolean} - Return true to signal stop descending.
*/
function depthLimiter (filePath, relativeTo, maxDepth) {
if (maxDepth === Infinity) return false
const rootDepth = relativeTo.split(path.sep).length
const fileDepth = filePath.split(path.sep).length
return fileDepth - rootDepth > maxDepth
}
/**
* Async iterable collector
*
* @async
* @function
* @private
*/
async function all (iterator) {
const collect = []
for await (const result of iterator) {
collect.push(result)
}
return collect
}
/**
* allFiles gives you all files from the directory walk as an array.
*
* @async
* @function
* @public
* @param {String|String[]} dirs - The path of the directory to walk, or an array of directory paths.
* @param {?(Opts)} opts - Options used for the directory walk.
*
* @returns {Promise<String[]|any>} - An async iterator that returns anything.
*/
async function allFiles (...args) {
return all(asyncFolderWalker(...args))
}
module.exports = {
asyncFolderWalker,
allFiles,
all
}

66
node_modules/async-folder-walker/package.json generated vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"_from": "async-folder-walker@^2.0.1",
"_id": "async-folder-walker@2.0.1",
"_inBundle": false,
"_integrity": "sha512-n0PW9w3HAZW7ems0XrgIYeX+3l2vX6HhZQyXMtkeKW3uEjHT5EOlKD8NgIeZK6fREnpw50F+Cb6ig3nWsuaTPA==",
"_location": "/async-folder-walker",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "async-folder-walker@^2.0.1",
"name": "async-folder-walker",
"escapedName": "async-folder-walker",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/async-neocities-tmp"
],
"_resolved": "https://registry.npmjs.org/async-folder-walker/-/async-folder-walker-2.0.1.tgz",
"_shasum": "cfc3007945a4bb109c5c548a0f07cd8a9cc15671",
"_spec": "async-folder-walker@^2.0.1",
"_where": "/Users/bret/repos/deploy-to-neocities/node_modules/async-neocities-tmp",
"author": {
"name": "Bret Comnes",
"email": "bcomnes@gmail.com",
"url": "https://bret.io"
},
"bugs": {
"url": "https://github.com/bcomnes/async-folder-walker/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "WIP - nothing to see here",
"devDependencies": {
"dependency-check": "^4.1.0",
"npm-run-all": "^4.1.5",
"p-temporary-directory": "^1.1.1",
"standard": "^14.3.1",
"tap": "^14.10.5"
},
"homepage": "https://github.com/bcomnes/async-folder-walker",
"keywords": [],
"license": "MIT",
"main": "index.js",
"name": "async-folder-walker",
"repository": {
"type": "git",
"url": "git+https://github.com/bcomnes/async-folder-walker.git"
},
"scripts": {
"debug": "node --nolazy --inspect-brk=9229 -r esm test.js",
"test": "run-s test:*",
"test:deps": "dependency-check . --no-dev --no-peer",
"test:standard": "standard",
"test:tap": "tap"
},
"standard": {
"ignore": [
"dist"
]
},
"version": "2.0.1"
}

102
node_modules/async-folder-walker/test.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
const tap = require('tap')
const { asyncFolderWalker, allFiles } = require('.')
const path = require('path')
const tmp = require('p-temporary-directory')
const fixtures = path.join(__dirname, 'fixtures')
tap.test('for of multiple folders', async t => {
for await (const file of asyncFolderWalker([
path.join(fixtures, 'sub-folder'),
path.join(fixtures, 'another-folder')
])) {
t.ok(file, file)
}
})
tap.test('Array from async iterator', async t => {
const files = await allFiles([
path.join(fixtures, 'sub-folder'),
path.join(fixtures, 'another-folder')
])
t.equal(files.length, 4, 'expected number of files are found')
})
tap.skip('Shape example', async t => {
await allFiles([fixtures], {
shaper: fwData => {
console.log(fwData)
return fwData
}
})
t.pass('shape printed')
})
tap.test('No args', async t => {
for await (const file of asyncFolderWalker()) {
t.fail(file, 'no files should be found!')
}
t.pass('for of executed')
})
tap.test('No folders', async t => {
const [dir, cleanup] = await tmp()
try {
for await (const file of asyncFolderWalker(dir)) {
t.fail(file, 'no files should be found!')
}
t.pass('for of executed')
} finally {
await cleanup()
}
})
tap.test('When you just pass a file', async t => {
const [dir, cleanup] = await tmp()
try {
const theFile = path.join(fixtures, 'test.json')
const files = await allFiles([theFile, dir])
t.equal(files.length, 1, 'only one file is found')
t.equal(theFile, files[0], 'only one file is found')
} finally {
await cleanup()
}
})
tap.test('pathFilter works', async t => {
const filterStrig = 'sub-folder'
const files = await allFiles(fixtures, {
pathFilter: p => !p.includes(filterStrig)
})
t.false(files.some(f => f.includes(filterStrig)), 'No paths include the excluded string')
})
tap.test('statFilter works', async t => {
const stats = await allFiles(fixtures, {
statFilter: st => !st.isDirectory(), // Exclude files
shaper: ({ root, filepath, stat, relname, basename }) => stat // Lets get the stats instead of paths
})
for (const st of stats) {
t.false(st.isDirectory(), 'none of the files are directories')
}
})
tap.test('dont include root directory in response', async (t) => {
const root = process.cwd()
for await (const file of asyncFolderWalker(root)) {
if (file === root) t.fail('root directory should not be in results')
}
t.pass('The root was not included in results.')
})
tap.test('dont walk past the maxDepth', async t => {
const maxDepth = 3
const walker = asyncFolderWalker(['.git', 'node_modules'], { maxDepth })
for await (const file of walker) {
const correctLength = file.split(path.sep).length - process.cwd().split(path.sep).length <= maxDepth
if (!correctLength) t.fail('walker walked past the depth it was supposed to')
}
t.pass('Walker was depth limited')
})