Skip to content

Commit

Permalink
new postinstall script
Browse files Browse the repository at this point in the history
  • Loading branch information
ellman committed Sep 14, 2014
1 parent 5219398 commit b50b3f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
44 changes: 27 additions & 17 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ var install = exports.install = function(module, options) {

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);

Expand All @@ -669,25 +673,8 @@ var install = exports.install = function(module, options) {
});
};

exports.preinstall = function() {

requiresRoot(function() {
loadPackageJson('./mean.json', function(err, data) {

if (err || !data) return;

for (var dep in data.dependencies) {

install(dep + '@' + data.dependencies[dep], {
skipNpm: true
});
}
});
});
};

exports.postinstall = function() {

requiresRoot(function() {
console.log(chalk.green('Installing Bower depenedencies'));
require('bower').commands.install().on('error', function(err) {
Expand All @@ -698,6 +685,12 @@ exports.postinstall = function() {
packagesNpmInstall('packages/custom');
packagesNpmInstall('packages/core');
packagesNpmInstall('packages/contrib');

// Load mean.json

var source = process.cwd();
packagesMeanJson(source);

});
};

Expand All @@ -714,6 +707,9 @@ function packagesNpmInstall(source) {

files.forEach(function(file) {
var pkgPath = path.join(packages, file);

packagesMeanJson(pkgPath);

loadPackageJson(path.join(pkgPath, 'package.json'), function(err, data) {
if (err || !data.mean) return;

Expand All @@ -731,6 +727,20 @@ function packagesNpmInstall(source) {
});
}

function packagesMeanJson(source) {
// Load mean.json
loadPackageJson(path.join(source, 'mean.json'), function(err, data) {
if (err || !data) return;

for (var dep in data.dependencies) {
install(dep + '@' + data.dependencies[dep], {
skipNpm: false
});
}
});

}

exports.uninstall = function(module) {
requiresRoot(function() {
console.log(chalk.yellow('Removing module:'), module);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meanio",
"version": "0.5.27",
"version": "0.5.28",
"preferGlobal": true,
"description": "Simple command line interface for installing and managing MEAN apps",
"author": {
Expand Down

0 comments on commit b50b3f7

Please sign in to comment.