Codibre/anypm

View on GitHub
src/lib/package-exists.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
const NpmApi = require('npm-api');
const npm = new NpmApi();

export function packageExists(pkg: string): Promise<boolean> {
    return npm
        .repo(pkg)
        .prop('deprecated')
        .then((x: string) => !x)
        .catch(() => false);
}