first commit
This commit is contained in:
38
node_modules/mkdirp/dist/cjs/src/opts-arg.js
generated
vendored
Normal file
38
node_modules/mkdirp/dist/cjs/src/opts-arg.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.optsArg = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const optsArg = (opts) => {
|
||||
if (!opts) {
|
||||
opts = { mode: 0o777 };
|
||||
}
|
||||
else if (typeof opts === 'object') {
|
||||
opts = { mode: 0o777, ...opts };
|
||||
}
|
||||
else if (typeof opts === 'number') {
|
||||
opts = { mode: opts };
|
||||
}
|
||||
else if (typeof opts === 'string') {
|
||||
opts = { mode: parseInt(opts, 8) };
|
||||
}
|
||||
else {
|
||||
throw new TypeError('invalid options argument');
|
||||
}
|
||||
const resolved = opts;
|
||||
const optsFs = opts.fs || {};
|
||||
opts.mkdir = opts.mkdir || optsFs.mkdir || fs_1.mkdir;
|
||||
opts.mkdirAsync = opts.mkdirAsync
|
||||
? opts.mkdirAsync
|
||||
: async (path, options) => {
|
||||
return new Promise((res, rej) => resolved.mkdir(path, options, (er, made) => er ? rej(er) : res(made)));
|
||||
};
|
||||
opts.stat = opts.stat || optsFs.stat || fs_1.stat;
|
||||
opts.statAsync = opts.statAsync
|
||||
? opts.statAsync
|
||||
: async (path) => new Promise((res, rej) => resolved.stat(path, (err, stats) => (err ? rej(err) : res(stats))));
|
||||
opts.statSync = opts.statSync || optsFs.statSync || fs_1.statSync;
|
||||
opts.mkdirSync = opts.mkdirSync || optsFs.mkdirSync || fs_1.mkdirSync;
|
||||
return resolved;
|
||||
};
|
||||
exports.optsArg = optsArg;
|
||||
//# sourceMappingURL=opts-arg.js.map
|
Reference in New Issue
Block a user