1.0.0 • Published 5 years ago

npm-cli-api v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

npm-cli-api

An API for npm using the npm CLI tool.

Usage

Get npm's version

const npm = require('npm-cli-api')

let version = npm.getVersion()
console.log(version)

Installing packages

const npm = require('npm-cli-api')

// Install foo-bar
npm.install('foo-bar')

// Update NPM itself via global install
npm.install('npm', options = { global: true })

Uninstalling packages

const npm = require('npm-cli-api')

// Install foo-bar
npm.uninstall('foo-bar')

// Uninstall global package 'cool-program'
npm.uninstall('cool-program', options = { global: true })

Search for packages

function callback(results) {
    // Do stuff with the search results
    for (let result in results) {
        console.log(result)
    }
}
// Search the official registry for npm-cli-api
search('npm-cli-api', null, callback)