Skip to content

Commit

Permalink
[major] change npm to optional dep by using canihaz, reduce package c…
Browse files Browse the repository at this point in the history
…onsumption
  • Loading branch information
Swaagie committed Dec 19, 2013
1 parent 2f17568 commit ba542a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
35 changes: 20 additions & 15 deletions lib/jitsu/commands/install.js
@@ -1,20 +1,22 @@
'use strict';

/*
* install.js: Commands for installing and deploying starter apps.
*
* (C) 2010, Nodejitsu Inc.
*
*/

var fs = require('fs'),
var canihaz = require('canihaz')('jitsu'),
fs = require('fs'),
path = require('path'),
exists = fs.exists || path.exists,
common = require('../common'),
cpr = common.cpr,
rimraf = common.rimraf,
npmModule = require('npm'),
wizard = require('wizard'),
jitsu = require('../../jitsu'),
utile = jitsu.common;
utile = jitsu.common,
npm;

//
// "nodeapps" is a hash of aliases and npm packages,
Expand Down Expand Up @@ -62,16 +64,19 @@ module.exports = function (requestedApp, callback) {
}
};

npmModule.load({ exit: false }, function (err) {
if (err) {
return callback(err);
}
canihaz.npm(function fetch(err, module) {
npm = module;
npm.load({ exit: false }, function (err) {
if (err) {
return callback(err);
}

if (typeof app.name === 'string') {
return createApp({starter: app.name}, callback);
}
if (typeof app.name === 'string') {
return createApp({starter: app.name}, callback);
}

promptforAppName(callback);
promptforAppName(callback);
});
});

function createApp(results, cb) {
Expand All @@ -90,7 +95,7 @@ module.exports = function (requestedApp, callback) {

jitsu.log.info('Installing ' + appName.magenta + ' locally');
jitsu.log.warn('Downloading packages from npm, this may take a moment...');
npmModule.commands.install(appName, [nodeapps[appName].package], function (err, result) {
npm.commands.install(appName, [nodeapps[appName].package], function (err, result) {
if (err) {
return cb(err);
}
Expand Down Expand Up @@ -148,7 +153,7 @@ module.exports = function (requestedApp, callback) {
jitsu.log.warn('Cancelled');
return cb(null, 'Cancelled');
}
return createApp({ starter: results['starter'] }, callback);
return createApp({ starter: results.starter }, callback);
});
}

Expand Down Expand Up @@ -234,7 +239,7 @@ module.exports = function (requestedApp, callback) {
jitsu.log.help('To exit the app, press CTRL-C \n');

if (dest === "local") {
return npmModule.start(process.cwd() + '/' + app.name, cb);
return npm.start(process.cwd() + '/' + app.name, cb);
}
}

Expand Down
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -20,6 +20,7 @@
},
"preferGlobal": true,
"dependencies": {
"canihaz": "1.0.0",
"colors": "0.6.2",
"complete": "0.3.1",
"dateformat": "1.0.2-1.2.3",
Expand All @@ -29,7 +30,6 @@
"fstream": "0.1.25",
"fstream-npm": "0.1.6",
"ladder": "0.0.1",
"npm": "1.3.15",
"nodejitsu-api": "0.5.3",
"opener": "1.3.x",
"pkginfo": "0.3.0",
Expand All @@ -41,6 +41,9 @@
"tar": "0.1.18",
"wizard": "0.0.1"
},
"canihaz": {
"npm": "1.3.15"
},
"devDependencies": {
"nock": "0.25.x",
"vows": "0.7.x"
Expand Down

0 comments on commit ba542a4

Please sign in to comment.