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

@ -1,11 +1,11 @@
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Node.js CI][ci-image]][ci-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Downloads][downloads-image]][downloads-url]
# removeNPMAbsolutePaths
removeNPMAbsolutePaths is a small utility to remove the fields that npm adds to the modules in `node_modules` containing local aboslute paths.
removeNPMAbsolutePaths is a small utility to remove the fields that npm adds to the modules in `node_modules` containing local absolute paths.
It has been noted that the `package.json` of modules in the `node_modules` folder contain some extra fields like `_args` and `where` which contain the absolute path of the module. According to NPM those fields are not even used.
@ -26,15 +26,19 @@ $ removeNPMAbsolutePaths '<PROJECT_FOLDER>'
```
or use it from whithin your code
```javascript
var removeNPMAbsolutePaths = require('removeNPMAbsolutePaths');
removeNPMAbsolutePaths('<PROJECT_FOLDER>')
.then(results => results.forEach(result => {
const removeNPMAbsolutePaths = require('removeNPMAbsolutePaths');
try {
const results = await removeNPMAbsolutePaths('<PROJECT_FOLDER>');
results.forEach(result => {
// Print only information about files that couldn't be processed
if (!result.success) {
console.log(result.err.message);
}
}))
.catch(err => console.log(err.message));
});
} catch(err) {
console.log(err.message);
}
```
Using `removeNPMAbsolutePaths` from within Javascript returns a promise containing information about all the folders and files processed and whether they where successfully processed and rewritten or not.
@ -61,8 +65,8 @@ MIT
[npm-image]: https://img.shields.io/npm/v/removeNPMAbsolutePaths.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/removeNPMAbsolutePaths
[travis-image]: https://img.shields.io/travis/juanjoDiaz/removeNPMAbsolutePaths/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/juanjoDiaz/removeNPMAbsolutePaths
[ci-image]: https://github.com/juanjoDiaz/removeNPMAbsolutePaths/actions/workflows/on-push.yaml/badge.svg
[ci-url]: https://github.com/juanjoDiaz/removeNPMAbsolutePaths/actions/workflows/on-push.yaml
[coveralls-image]: https://img.shields.io/coveralls/juanjoDiaz/removeNPMAbsolutePaths/master.svg?style=flat-square
[coveralls-url]: https://coveralls.io/github/juanjoDiaz/removeNPMAbsolutePaths?branch=master
[downloads-image]: https://img.shields.io/npm/dm/removeNPMAbsolutePaths.svg?style=flat-square

View file

@ -1,6 +1,6 @@
{
"name": "removeNPMAbsolutePaths",
"version": "2.0.0",
"version": "3.0.0",
"description": "Remove the fields containing local aboslute paths created by NPM",
"keywords": [
"npm",
@ -10,9 +10,7 @@
"scripts": {
"lint": "eslint bin/removeNPMAbsolutePaths src test --ignore-pattern 'test/data/malformed/module/'",
"test": "mocha test",
"test-with-coverage": "nyc --reporter=text mocha test",
"travis": "npm run lint && npm run test-with-coverage",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
"test-with-coverage": "nyc --reporter=text --reporter=lcov mocha test"
},
"author": "Juanjo Diaz <juanjo.diazmo@gmail.com>",
"repository": {
@ -35,18 +33,18 @@
"src/"
],
"devDependencies": {
"chai": "^4.2.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.0.5",
"eslint": "^6.0.1",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-import": "^2.18.0",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"sinon": "^7.3.2",
"sinon-chai": "^3.3.0"
"coveralls": "^3.1.1",
"eslint": "^8.9.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4",
"mocha": "^9.2.1",
"nyc": "^15.1.0",
"sinon": "^13.0.1",
"sinon-chai": "^3.7.0"
},
"engines": {
"node": ">=4.0.0"
}
}
}

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.');
}