Package Exports
- @azu/npm-programmatic
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@azu/npm-programmatic) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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-programmaticInstallation 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