Skip to content

Commit

Permalink
Combine meanio and mean-cli preinstall scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fyockm committed Oct 20, 2014
1 parent 0a82b97 commit 1393821
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions scripts/preinstall.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
process.argv.forEach(function(arg) {
if (['-g', '--global'].indexOf(arg) > -1) {
console.log('Please install \'mean-cli\' globally instead of \'meanio\' as:');
console.log('');
console.log(' $ npm install -g mean-cli');
console.log('');
process.exit(1);
}
});
var args = process.argv.slice(2);

if (~args.indexOf('meanio') && (~args.indexOf('-g') || ~args.indexOf('--global'))) {
console.log('Please install \'mean-cli\' globally instead of \'meanio\' as:');
console.log('');
console.log(' $ npm install -g mean-cli');
console.log('');
process.exit(1);
} else if (~args.indexOf('mean-cli')) {
var spawn = require('child_process').spawn;
npmls = spawn('npm', ['ls', '--global', '--parseable', '--depth', '0']),
grep = spawn('grep', ['meanio']);

npmls.stdout.on('data', function(data) {
grep.stdin.write(data);
});

npmls.on('close', function(code) {
grep.stdin.end();
});

grep.stdout.on('data', function(data) {
console.log('' + data);
});

grep.on('close', function(code) {
// meanio global was found
if (code === 0) {
console.log(' Please run \'npm uninstall -g meanio\' prior to installing mean-cli');
console.log('');
process.exit(1);
}
});
}

0 comments on commit 1393821

Please sign in to comment.