# @azu/npm-programmatic

> Use NPM commands programmatically

Latest version **0.2.0** (published 2017-01-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @azu/npm-programmatic
pnpm add @azu/npm-programmatic
yarn add @azu/npm-programmatic
bun add @azu/npm-programmatic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-01-09 |
| First published | 2017-01-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | manak |
| Maintainers | azu |
| Keywords | npm, programmatic |

## Links

- npm: https://www.npmjs.com/package/@azu/npm-programmatic
- Repository: https://github.com/azu/npm-programmatic
- Homepage: https://github.com/azu/npm-programmatic#readme
- Issues: https://github.com/azu/npm-programmatic/issues
- npm.io page: https://npm.io/package/@azu/npm-programmatic

## Dependencies (2)

- [npm](https://npm.io/package/npm.md) ^4.0.5
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.7

## Recent versions

- 0.2.0 (latest) — 2017-01-09
- 0.1.1 — 2017-01-06

## README

# npm-programmatic [![Build Status](https://travis-ci.org/azu/npm-programmatic.svg?branch=master)](https://travis-ci.org/azu/npm-programmatic)   

npm-programmatic is a library that allows you to access npm commands programmatically from javascript
## Usage
Every function returns a Bluebird promise.   
CWD refers to current working directory, allowing you to ensure the command executes in a certain folder in the filesystem.
If output is set, the output of npm will be shown in the console.

## Installation

    npm install @azu/npm-programmatic

## Installation of Packages

``` 
    npm.install(packages, opts).then(function)
```
| Name        | Type           | Value  |
| ------------- |:-------------:| -----:|
| packages      | Array      |   packages to be installed |
| opts      | Object | save:true/false; global:true/false; cwd:string; saveDev:true/false; output:true/false|

### Example
``` 
    var npm = require('@azu/npm-programmatic');
    npm.install(['left-pad'], {
        cwd:'/path/to/my/project',
        save:true
    })
    .then(function(){
        console.log("SUCCESS!!!");
    })
    .catch(function(){
        console.log("Unable to install package");
    });
```

## Unistallation of Packages

``` 
    npm.uninstall(packages, opts).then(function)
```
| Name        | Type           | Value  |
| ------------- |:-------------:| -----:|
| packages      | Array      |   packages to be uninstalled |
| opts      | Object | save:true/false; global:true/false; cwd:string; saveDev:true/false; output:true/false|

### Example
``` 
    var npm = require('@azu/npm-programmatic');
    npm.install(['left-pad'], {
        cwd:'/path/to/my/project',
        save:true
    })
    .then(function(){
        console.log("SUCCESS!!!");
    })
    .catch(function(){
        console.log("Unable to uninstall package");
    });
```


## List Installed Packages

``` 
    npm.list(path).then(function)
```
| Name        | Type           | Value  |
| ------------- |:-------------:| -----:|
| path      | String      |   path at which to look |

### Example
``` 
    var npm = require('@azu/npm-programmatic');
    npm.list('/path/to/project')
    .then(function(arrayOfPackages){
        console.log(arrayOfPackages);
    })
    .catch(function(){
        console.log("Unable to uninstall package");
    });
```

## Tests
install mocha and dev dependencies. Then run 
``` npm test    ```

---
_Source: https://npm.io/package/@azu/npm-programmatic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
