Initial import with skill sheet working
This commit is contained in:
21
node_modules/fs-mkdirp-stream/LICENSE
generated
vendored
Normal file
21
node_modules/fs-mkdirp-stream/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017, 2020-2021 Blaine Bublitz <blaine.bublitz@gmail.com> and Eric Schoffstall <yo@contra.io>
|
||||
|
||||
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.
|
63
node_modules/fs-mkdirp-stream/README.md
generated
vendored
Normal file
63
node_modules/fs-mkdirp-stream/README.md
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<p align="center">
|
||||
<a href="https://gulpjs.com">
|
||||
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# fs-mkdirp-stream
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
|
||||
|
||||
Ensure directories exist before writing to them.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var { Readable, Writable } = require('streamx');
|
||||
var mkdirpStream = require('fs-mkdirp-stream');
|
||||
|
||||
Readable.from([{ dirname: './path/to/my/', path: './path/to/my/file.js' }])
|
||||
.pipe(
|
||||
mkdirpStream(function (obj, callback) {
|
||||
// callback can take 3 arguments (err, dirname, mode)
|
||||
callback(null, obj.dirname);
|
||||
})
|
||||
)
|
||||
.pipe(
|
||||
new Writable({
|
||||
write: function (obj, cb) {
|
||||
// This will be called once the directory exists
|
||||
// obj === { dirname: '/path/to/my/', path: '/path/to/my/file.js' }
|
||||
cb();
|
||||
},
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `mkdirpStream(resolver)`
|
||||
|
||||
Takes a `resolver` function or string and returns a `streamx.Transform` stream.
|
||||
|
||||
If the `resolver` is a function, it will be called once per chunk with the signature `(chunk, callback)`. The `callback(error, dirpath, mode)` must be called with the `dirpath` to be created as the 2nd parameter or an `error` as the 1st parameter; optionally with a `mode` as the 3rd parameter.
|
||||
|
||||
If the `resolver` is a string, it will be created/ensured for each chunk (e.g. if it were deleted between chunks, it would be recreated). When using a string, a custom `mode` can't be used.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
Contains a custom implementation of `mkdirp` originally based on https://github.com/substack/node-mkdirp (Licensed MIT/X11 - Copyright 2010 James Halliday) with heavy modification to better support custom modes.
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
[downloads-image]: https://img.shields.io/npm/dm/fs-mkdirp-stream.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/fs-mkdirp-stream
|
||||
[npm-image]: https://img.shields.io/npm/v/fs-mkdirp-stream.svg?style=flat-square
|
||||
|
||||
[ci-url]: https://github.com/gulpjs/fs-mkdirp-stream/actions?query=workflow:dev
|
||||
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/fs-mkdirp-stream/dev?style=flat-square
|
||||
|
||||
[coveralls-url]: https://coveralls.io/r/gulpjs/fs-mkdirp-stream
|
||||
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/fs-mkdirp-stream/master.svg?style=flat-square
|
||||
<!-- prettier-ignore-end -->
|
44
node_modules/fs-mkdirp-stream/index.js
generated
vendored
Normal file
44
node_modules/fs-mkdirp-stream/index.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var Transform = require('streamx').Transform;
|
||||
|
||||
var mkdirp = require('./mkdirp');
|
||||
|
||||
function toFunction(dirpath) {
|
||||
function stringResolver(chunk, callback) {
|
||||
callback(null, dirpath);
|
||||
}
|
||||
|
||||
return stringResolver;
|
||||
}
|
||||
|
||||
function mkdirpStream(resolver) {
|
||||
// Handle resolver that's just a dirpath
|
||||
if (typeof resolver === 'string') {
|
||||
resolver = toFunction(resolver);
|
||||
}
|
||||
|
||||
return new Transform({
|
||||
transform: function (chunk, callback) {
|
||||
resolver(chunk, onDirpath);
|
||||
|
||||
function onDirpath(dirpathErr, dirpath, mode) {
|
||||
if (dirpathErr) {
|
||||
return callback(dirpathErr);
|
||||
}
|
||||
|
||||
mkdirp(dirpath, mode, onMkdirp);
|
||||
}
|
||||
|
||||
function onMkdirp(mkdirpErr) {
|
||||
if (mkdirpErr) {
|
||||
return callback(mkdirpErr);
|
||||
}
|
||||
|
||||
callback(null, chunk);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = mkdirpStream;
|
143
node_modules/fs-mkdirp-stream/mkdirp.js
generated
vendored
Normal file
143
node_modules/fs-mkdirp-stream/mkdirp.js
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var fs = require('graceful-fs');
|
||||
|
||||
var MASK_MODE = parseInt('7777', 8);
|
||||
|
||||
// Utility for passing dirpath that was used with `fs.stat`
|
||||
function stat(dirpath, cb) {
|
||||
fs.stat(dirpath, onStat);
|
||||
|
||||
function onStat(err, stats) {
|
||||
cb(err, dirpath, stats);
|
||||
}
|
||||
}
|
||||
|
||||
// Utility for passing dirpath that was used with `fs.lstat`
|
||||
function lstat(dirpath, cb) {
|
||||
fs.lstat(dirpath, onStat);
|
||||
|
||||
function onStat(err, stats) {
|
||||
cb(err, dirpath, stats);
|
||||
}
|
||||
}
|
||||
|
||||
function mkdirp(dirpath, mode, callback) {
|
||||
if (typeof mode === 'function') {
|
||||
callback = mode;
|
||||
mode = undefined;
|
||||
}
|
||||
|
||||
if (typeof mode === 'string') {
|
||||
mode = parseInt(mode, 8);
|
||||
}
|
||||
|
||||
dirpath = path.resolve(dirpath);
|
||||
|
||||
fs.mkdir(dirpath, mode, onMkdir);
|
||||
|
||||
function onMkdir(mkdirErr) {
|
||||
if (!mkdirErr) {
|
||||
return stat(dirpath, onStat);
|
||||
}
|
||||
|
||||
switch (mkdirErr.code) {
|
||||
case 'ENOENT': {
|
||||
return mkdirp(path.dirname(dirpath), onRecurse);
|
||||
}
|
||||
|
||||
case 'EEXIST': {
|
||||
return stat(dirpath, onStat);
|
||||
}
|
||||
|
||||
case 'ENOTDIR': {
|
||||
// On ENOTDIR, this will traverse up the tree until it finds something it can stat
|
||||
return stat(dirpath, onErrorRecurse);
|
||||
}
|
||||
|
||||
default: {
|
||||
return callback(mkdirErr);
|
||||
}
|
||||
}
|
||||
|
||||
function onErrorRecurse(err, dirpath, stats) {
|
||||
if (err) {
|
||||
return stat(path.dirname(dirpath), onErrorRecurse);
|
||||
}
|
||||
|
||||
onStat(err, dirpath, stats);
|
||||
}
|
||||
|
||||
function onStat(statErr, dirpath, stats) {
|
||||
if (statErr) {
|
||||
// If we have ENOENT here it might be a symlink,
|
||||
// so we need to recurse to error with the target file name
|
||||
if (statErr.code === 'ENOENT') {
|
||||
return lstat(dirpath, onStat);
|
||||
}
|
||||
|
||||
return callback(statErr);
|
||||
}
|
||||
|
||||
if (!stats.isDirectory()) {
|
||||
return lstat(dirpath, onNonDirectory);
|
||||
}
|
||||
|
||||
if (!mode) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
if ((stats.mode & MASK_MODE) === mode) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
fs.chmod(dirpath, mode, onChmod);
|
||||
}
|
||||
|
||||
function onChmod(chmodErr) {
|
||||
if (chmodErr && chmodErr.code !== 'ENOSUP') {
|
||||
return callback(chmodErr);
|
||||
}
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
function onNonDirectory(err, dirpath, stats) {
|
||||
if (err) {
|
||||
// Just being cautious by bubbling the mkdir error
|
||||
return callback(mkdirErr);
|
||||
}
|
||||
|
||||
if (stats.isSymbolicLink()) {
|
||||
return fs.readlink(dirpath, onReadlink);
|
||||
}
|
||||
|
||||
// Trying to readdir will surface the ENOTDIR we want
|
||||
// TODO: Use `opendir` when we support node >12
|
||||
fs.readdir(dirpath, callback);
|
||||
}
|
||||
|
||||
function onReadlink(err, link) {
|
||||
if (err) {
|
||||
// Just being cautious by bubbling the mkdir error
|
||||
return callback(mkdirErr);
|
||||
}
|
||||
|
||||
// Trying to readdir will surface the ENOTDIR we want
|
||||
// TODO: Use `opendir` when we support node >12
|
||||
fs.readdir(link, callback);
|
||||
}
|
||||
}
|
||||
|
||||
function onRecurse(recurseErr) {
|
||||
if (recurseErr) {
|
||||
return callback(recurseErr);
|
||||
}
|
||||
|
||||
mkdirp(dirpath, mode, callback);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mkdirp;
|
58
node_modules/fs-mkdirp-stream/package.json
generated
vendored
Normal file
58
node_modules/fs-mkdirp-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "fs-mkdirp-stream",
|
||||
"version": "2.0.1",
|
||||
"description": "Ensure directories exist before writing to them.",
|
||||
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
|
||||
"contributors": [
|
||||
"Blaine Bublitz <blaine.bublitz@gmail.com>"
|
||||
],
|
||||
"repository": "gulpjs/fs-mkdirp-stream",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"mkdirp.js"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"pretest": "npm run lint",
|
||||
"test": "nyc mocha --async-only"
|
||||
},
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.2.8",
|
||||
"streamx": "^2.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-gulp": "^5.0.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"expect": "^27.4.2",
|
||||
"mocha": "^8.4.0",
|
||||
"nyc": "^15.1.0",
|
||||
"readable-stream": "^3.6.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"sinon": "^12.0.1"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
"keywords": [
|
||||
"fs",
|
||||
"mkdirp",
|
||||
"stream",
|
||||
"mkdir",
|
||||
"directory",
|
||||
"directories",
|
||||
"ensure"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user