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) 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,