From f0ee0ac489fe2c2c06db299d75cfe603c15f0100 Mon Sep 17 00:00:00 2001 From: Yonatan Ellman Date: Sun, 14 Sep 2014 15:31:26 +0300 Subject: [PATCH] postinstall refactor --- lib/cli.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index f6afcc82..44b0a79f 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -619,7 +619,9 @@ var install = exports.install = function(module, options) { module = module.split('@'); var packageName = module[0]; - var tag = module[1] || 'master'; + var tag = 'master'; + + tag = tag === 'latest' ? 'master' : tag; getPackage(packageName, function(data) { console.log(chalk.green('Installing module: %s:'), module[0]); @@ -645,25 +647,27 @@ var install = exports.install = function(module, options) { shell.rm('-rf', destination + data.name + '/.git'); shell.rm('-rf', destination + data.name + '/.gitignore'); - shell.cd(pkgPath); + // Load mean.json + packagesMeanJson(__dirname); if (options.skipNpm) return; + + // Load package.json + loadPackageJson(pkgPath+'/package.json', function(err, data) { + if (err) return console.error(err); - shell.exec('npm install .', function(code) { - - if (code) return console.log(code); - - // Load mean.json - packagesMeanJson(__dirname); - - // Load package.json - loadPackageJson('./package.json', function(err, data) { - if (err) return console.error(err); - + console.log(); + if (!data.mean) { console.log(); - if (!data.mean) { - console.log(); - console.log(chalk.yellow('Warning: The module installed is not a valid MEAN module')); + console.log(chalk.yellow('Warning: The module installed is not a valid MEAN module')); + } + + npm.commands.install(pkgPath, [pkgPath], function(err) { + if (err) { + console.log(chalk.red('Error: npm install failed')); + return console.error(err); + } else { + console.log(chalk.green(' Dependencies installed for package ' + data.name)); } }); }); @@ -681,13 +685,12 @@ exports.postinstall = function() { console.log(chalk.red(err)); }); + packagesNpmInstall('packages'); packagesNpmInstall('packages/custom'); packagesNpmInstall('packages/core'); - packagesNpmInstall('packages/contrib'); // Load mean.json - var source = process.cwd(); packagesMeanJson(source);