Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add "npm dep" command

Installs dependencies as advertised in package.json
  • Loading branch information...
commit f91dc758a06f9af97d4e97b7750f1e87572e3a58 1 parent f27817b
@agnoster authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/commands/npm.js
View
19 lib/commands/npm.js
@@ -1,4 +1,23 @@
function npm(action, package, app) {
+ if (/^dep/.exec(action)) {
+ function _cb(err, json) {
+ var p;
+ if (err) this.fatal('Problem reading package.json: ' + err.message)
+ if (!json || !json.hasOwnProperty('dependencies')) this.fatal('No dependencies declared in package.json')
+ for (p in json.dependencies) {
+ if (!json.dependencies.hasOwnProperty(p)) continue
+ package = p + '@' + json.dependencies[p]
+ return this.apiCall('[npm] Installing ' + package, ['appnpm_install', app, package], function(data) {
+ delete(json.dependencies[p])
+ _cb(null, json)
+ })
+ }
+ return
+ }
+ _cb = _cb.bind(this)
+ console.log('# Installing depencies from package.json')
+ return this.config.pkg(_cb)
+ }
this.apiCall('[npm] ' + action + ' ' + package, ['appnpm_handler', app, package, action], function(data) {
console.log(data.output.trim())
this.ok('Call succeeded')
Please sign in to comment.
Something went wrong with that request. Please try again.