Fast and Programmatically npm outdated --json
implementation that use pacote to achieve similar result.
- Node.js v16 or higher
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i fast-outdated
# or
$ yarn add fast-outdated
const { outdated, clearCache } = require("fast-outdated");
async function main() {
clearCache();
const data = await outdated(void 0, { devDependencies: true });
console.log(JSON.stringify(data, null, 4));
}
main().catch(console.error);
declare namespace Outdated {
interface Packages {
[packageName: string]: {
wanted: string;
current: string;
latest: string;
location: string;
}
}
interface Options {
devDependencies?: boolean;
token?: string;
}
export function outdated(cwd?: string, options?: Options): Promise<Packages>;
export function clearCache(): any;
}
export as namespace Outdated;
export = Outdated;
Will give you equivalent result that the command npm outdated --json
. The default cwd value will be equal to process.cwd()
.
Options:
name | default value | description |
---|---|---|
devDependencies | false | Include devDependencies |
token | undefined | npm token for private packages |
Call pacote.clearMemoized
.
- Improve test suite
MIT