From e4a84074491d577b250e9432c9f248d56e255f5b Mon Sep 17 00:00:00 2001 From: Collin Bourdage Date: Fri, 9 Apr 2021 11:02:29 -0500 Subject: [PATCH 1/2] Adding support for exclude * Added support for an exclude option to be able to explicitly exclude packages from the outdated list of packages. --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1cb3a55..d94ae2e 100644 --- a/index.js +++ b/index.js @@ -28,11 +28,16 @@ const execP = outdatedCommand => { }; export default async function npmOutdated(options = {}) { + const exclude = (options && options.exclude) || []; + if (exclude && !Array.isArray(exclude)) { + throw new TypeError('exclude option must be of type string[] containing package names to exclude'); + } + let outdatedCommand = "npm outdated --json"; try { const outdatedPackages = await execP(outdatedCommand); - const packageNames = Object.keys(outdatedPackages); + const packageNames = Object.keys(outdatedPackages).filter((packageName) => !exclude.includes(packageName)); if (packageNames.length) { const packagesTable = formatOutdatedPackages( outdatedPackages, From 062a228b61a777ea88351a4b867e202daa69aab5 Mon Sep 17 00:00:00 2001 From: Collin Bourdage Date: Fri, 9 Apr 2021 11:09:04 -0500 Subject: [PATCH 2/2] Documentation update to support new option definition --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index a883baf..01366e4 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,17 @@ import npmOutdated from "danger-plugin-npm-outdated"; // Note: You need to use schedule() schedule(npmOutdated()); + +// example using options +schedule(npmOutdated({ exclude: ['package-name'] })); ``` +## Options +| Option | Type | Default | +| ------ | ---- | ------- | +| `exclude` | `string[]` | `[]` | + + ## Sample message ![sample message](https://raw.githubusercontent.com/revathskumar/danger-plugin-npm-outdated/master/images/message.png)