Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2022-02-24 17:03:29 +00:00
parent 4e02f8e87a
commit 0da815296a
500 changed files with 538 additions and 544 deletions

View file

@ -303,8 +303,7 @@ const all = [
},
];
module.exports = {};
all.forEach((error) => {
module.exports[error.errno] = error.description;
});
module.exports = all.reduce((obj, error) => ({
...obj,
[error.errno]: error.description,
}));

View file

@ -3,14 +3,9 @@
const path = require('path');
const {
stat, readdir, readFile, writeFile,
} = require('fs');
const { promisify } = require('util');
const errno = require('./errno');
} = require('fs').promises;
const statAsync = promisify(stat);
const readdirAsync = promisify(readdir);
const readFileAsync = promisify(readFile);
const writeFileAsync = promisify(writeFile);
const errno = require('./errno');
class ProcessingError extends Error {
constructor(message, err) {
@ -21,7 +16,7 @@ class ProcessingError extends Error {
async function getStats(filePath) {
try {
return await statAsync(filePath);
return await stat(filePath);
} catch (err) {
throw new ProcessingError(`Can't read directory/file at "${filePath}"`, err);
}
@ -31,7 +26,7 @@ async function processFile(filePath, opts) {
try {
let data;
try {
data = await readFileAsync(filePath, 'utf8');
data = await readFile(filePath, 'utf8');
} catch (err) {
throw new ProcessingError(`Can't read file at "${filePath}"`, err);
}
@ -54,7 +49,7 @@ async function processFile(filePath, opts) {
if (shouldWriteFile || opts.force) {
try {
await writeFileAsync(filePath, JSON.stringify(obj, null, ' '));
await writeFile(filePath, `${JSON.stringify(obj, null, ' ')}${data.endsWith('\n') ? '\n' : ''}`);
} catch (err) {
throw new ProcessingError(`Can't write processed file to "${filePath}"`, err);
}
@ -72,7 +67,7 @@ async function processDir(dirPath, opts) {
try {
let files;
try {
files = await readdirAsync(dirPath);
files = await readdir(dirPath);
} catch (err) {
throw new ProcessingError(`Can't read directory at "${dirPath}"`, err);
}
@ -98,26 +93,23 @@ async function processDir(dirPath, opts) {
return arr;
}
if (value.constructor === Array) {
return arr.concat(value);
if (Array.isArray(value)) {
return [...arr, ...value];
}
arr.push(value);
return arr;
return [...arr, value];
}, [{ dirPath, success: true }]);
} catch (err) {
return [{ dirPath, err, success: false }];
}
}
async function removeNPMAbsolutePaths(filePath, opts) {
opts = opts || {}; // eslint-disable-line no-param-reassign
async function removeNPMAbsolutePaths(filePath, opts = {}) {
if (!filePath) {
throw new ProcessingError('Missing path.\nThe first argument should be the path to a directory or a package.json file.');
}
if (opts.fields && (opts.fields.constructor !== Array || opts.fields.length === 0)) {
if (opts.fields && (!Array.isArray(opts.fields) || opts.fields.length === 0)) {
throw new ProcessingError('Invalid option: fields.\nThe fields option should be an array cotaining the names of the specific fields that should be removed.');
}