Skip to content

Consider using libnpm instead of spawning npm process #83

@betalb

Description

@betalb

Consider using libnpm instead of spawning npm process in npm plugin

Every piece of information that is currently used by npm plugin can be acquired through libnpm without using npm cli directly.

versions property is sorted by npm cli view command (https://github.com/npm/cli/blob/656bce7dd0f9753a273912e803261ed246593924/lib/view.js#L50)

const packument = require('libnpm/packument');
const semver = require('semver');

packument('libnpm', {
    fullMetadata: true
}).then((data) => {
    const distTags = data["dist-tags"] || {};
    console.log({
        name: data.name,
        description: data.description,
        latestVersion: distTags.latest,
        nextVersion: distTags.next,
        versions: Object.keys(data.versions).sort(semver.compareLoose),
    });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions