Update checked-in dependencies
This commit is contained in:
parent
fa428daf9c
commit
b3bf514df4
216 changed files with 4342 additions and 1611 deletions
49
node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
generated
vendored
49
node_modules/enhanced-resolve/lib/DescriptionFileUtils.js
generated
vendored
|
|
@ -8,11 +8,14 @@
|
|||
const forEachBail = require("./forEachBail");
|
||||
|
||||
/** @typedef {import("./Resolver")} Resolver */
|
||||
/** @typedef {import("./Resolver").JsonObject} JsonObject */
|
||||
/** @typedef {import("./Resolver").JsonValue} JsonValue */
|
||||
/** @typedef {import("./Resolver").ResolveContext} ResolveContext */
|
||||
/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
|
||||
|
||||
/**
|
||||
* @typedef {Object} DescriptionFileInfo
|
||||
* @property {any=} content
|
||||
* @property {JsonObject=} content
|
||||
* @property {string} path
|
||||
* @property {string} directory
|
||||
*/
|
||||
|
|
@ -23,6 +26,13 @@ const forEachBail = require("./forEachBail");
|
|||
* @param {DescriptionFileInfo=} result
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Result
|
||||
* @property {string} path path to description file
|
||||
* @property {string} directory directory of description file
|
||||
* @property {JsonObject} content content of description file
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Resolver} resolver resolver
|
||||
* @param {string} directory directory
|
||||
|
|
@ -46,12 +56,20 @@ function loadDescriptionFile(
|
|||
}
|
||||
forEachBail(
|
||||
filenames,
|
||||
/**
|
||||
* @param {string} filename filename
|
||||
* @param {(err?: null|Error, result?: null|Result) => void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
(filename, callback) => {
|
||||
const descriptionFilePath = resolver.join(directory, filename);
|
||||
if (resolver.fileSystem.readJson) {
|
||||
resolver.fileSystem.readJson(descriptionFilePath, (err, content) => {
|
||||
if (err) {
|
||||
if (typeof err.code !== "undefined") {
|
||||
if (
|
||||
typeof (/** @type {NodeJS.ErrnoException} */ (err).code) !==
|
||||
"undefined"
|
||||
) {
|
||||
if (resolveContext.missingDependencies) {
|
||||
resolveContext.missingDependencies.add(descriptionFilePath);
|
||||
}
|
||||
|
|
@ -78,13 +96,15 @@ function loadDescriptionFile(
|
|||
if (resolveContext.fileDependencies) {
|
||||
resolveContext.fileDependencies.add(descriptionFilePath);
|
||||
}
|
||||
|
||||
/** @type {JsonObject | undefined} */
|
||||
let json;
|
||||
|
||||
if (content) {
|
||||
try {
|
||||
json = JSON.parse(content.toString());
|
||||
} catch (e) {
|
||||
return onJson(e);
|
||||
} catch (/** @type {unknown} */ e) {
|
||||
return onJson(/** @type {Error} */ (e));
|
||||
}
|
||||
} else {
|
||||
return onJson(new Error("No content in file"));
|
||||
|
|
@ -94,6 +114,11 @@ function loadDescriptionFile(
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {null|Error} [err] error
|
||||
* @param {JsonObject} [content] content
|
||||
* @returns {void}
|
||||
*/
|
||||
function onJson(err, content) {
|
||||
if (err) {
|
||||
if (resolveContext.log)
|
||||
|
|
@ -106,12 +131,17 @@ function loadDescriptionFile(
|
|||
return callback(err);
|
||||
}
|
||||
callback(null, {
|
||||
content,
|
||||
content: /** @type {JsonObject} */ (content),
|
||||
directory,
|
||||
path: descriptionFilePath
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {null|Error} [err] error
|
||||
* @param {null|Result} [result] result
|
||||
* @returns {void}
|
||||
*/
|
||||
(err, result) => {
|
||||
if (err) return callback(err);
|
||||
if (result) {
|
||||
|
|
@ -131,20 +161,21 @@ function loadDescriptionFile(
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {any} content content
|
||||
* @param {JsonObject} content content
|
||||
* @param {string|string[]} field field
|
||||
* @returns {object|string|number|boolean|undefined} field data
|
||||
* @returns {JsonValue | undefined} field data
|
||||
*/
|
||||
function getField(content, field) {
|
||||
if (!content) return undefined;
|
||||
if (Array.isArray(field)) {
|
||||
/** @type {JsonValue} */
|
||||
let current = content;
|
||||
for (let j = 0; j < field.length; j++) {
|
||||
if (current === null || typeof current !== "object") {
|
||||
current = null;
|
||||
break;
|
||||
}
|
||||
current = current[field[j]];
|
||||
current = /** @type {JsonObject} */ (current)[field[j]];
|
||||
}
|
||||
return current;
|
||||
} else {
|
||||
|
|
@ -162,7 +193,7 @@ function cdUp(directory) {
|
|||
j = directory.lastIndexOf("\\");
|
||||
const p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
|
||||
if (p < 0) return null;
|
||||
return directory.substr(0, p || 1);
|
||||
return directory.slice(0, p || 1);
|
||||
}
|
||||
|
||||
exports.loadDescriptionFile = loadDescriptionFile;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue