From 2383dff317fca7adb04e4002758fc4bbb7910825 Mon Sep 17 00:00:00 2001 From: Kit Cambridge Date: Thu, 18 Oct 2012 09:43:35 -0700 Subject: [PATCH] Avoid including npm as a dependency; parse the `npm -g root` output directly. Former-commit-id: a6b432de64292ce2af280d0a861f610ceeabce6c --- build/post-install.js | 40 ++++++++++++++++++---------------------- package.json | 3 --- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/build/post-install.js b/build/post-install.js index 89bcebbe4..75a9dc342 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -7,8 +7,8 @@ zlib = require('zlib'), path = require('path'), https = require('https'), - tar = require('tar'), - npm = require('npm'); + exec = require('child_process').exec, + tar = require('tar'); /** The directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); @@ -58,31 +58,27 @@ }).on('error', callback); } - npm.load({ - 'global': true - }, function(exception) { - if (exception) { - process.stderr.write('There was a problem loading the npm registry.'); + exec('npm -g root', function(exception, stdout, stderr) { + if (exception || stderr) { + console.error('There was a problem loading the npm registry.'); process.exit(1); - } else { - if (path.resolve(basePath, '..') == npm.root) { - // download Closure Compiler - getDependency('aa29a2ecf6f51d4da5a2a418c0d4ea0e368ee80d', vendorPath, function(exception) { - var statusCode = 0; + } else if (path.resolve(basePath, '..') == stdout.trim()) { + // download Closure Compiler + getDependency('aa29a2ecf6f51d4da5a2a418c0d4ea0e368ee80d', vendorPath, function(exception) { + var statusCode = 0; + if (exception) { + console.error('There was a problem downloading the Closure Compiler.'); + statusCode = 1; + } + // download UglifyJS + getDependency('827f406a02626c1c6723e8ae281b6785d36375c1', vendorPath, function(exception) { if (exception) { - process.stderr.write('There was a problem downloading Closure Compiler.'); + console.error('There was a problem downloading UglifyJS.'); statusCode = 1; } - // download UglifyJS - getDependency('827f406a02626c1c6723e8ae281b6785d36375c1', vendorPath, function(exception) { - if (exception) { - process.stderr.write('There was a problem downloading UglifyJS.'); - statusCode = 1; - } - process.exit(statusCode); - }); + process.exit(statusCode); }); - } + }); } }); }()); diff --git a/package.json b/package.json index b59d01517..dd6fa273c 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,6 @@ "dependencies": { "tar": "~0.1.13" }, - "devDependencies": { - "npm": "~1.1.63" - }, "bugs": { "url": "https://github.com/bestiejs/lodash/issues" },