diff --git a/cli/pbjs.js b/cli/pbjs.js index ede8cb00a..63b4a543d 100644 --- a/cli/pbjs.js +++ b/cli/pbjs.js @@ -4,8 +4,6 @@ var path = require("path"), pkg = require("./package.json"), util = require("./util"); -util.setup(); - var protobuf = require(util.pathToProtobufJs), minimist = require("minimist"), chalk = require("chalk"), diff --git a/cli/pbts.js b/cli/pbts.js index cbe23cb8f..45256b88e 100644 --- a/cli/pbts.js +++ b/cli/pbts.js @@ -2,10 +2,7 @@ var child_process = require("child_process"), path = require("path"), fs = require("fs"), - pkg = require("./package.json"), - util = require("./util"); - -util.setup(); + pkg = require("./package.json"); var minimist = require("minimist"), chalk = require("chalk"), diff --git a/cli/util.js b/cli/util.js index ffce1ed7e..52202370c 100644 --- a/cli/util.js +++ b/cli/util.js @@ -1,9 +1,6 @@ "use strict"; var fs = require("fs"), - path = require("path"), - child_process = require("child_process"); - -var semver; + path = require("path"); try { // installed as a peer dependency @@ -113,49 +110,6 @@ exports.inspect = function inspect(object, indent) { return sb.join("\n"); }; -function modExists(name, version) { - for (var i = 0; i < module.paths.length; ++i) { - try { - var pkg = JSON.parse(fs.readFileSync(path.join(module.paths[i], name, "package.json"))); - return semver - ? semver.satisfies(pkg.version, version) - : parseInt(pkg.version, 10) === parseInt(version.replace(/^[\^~]/, ""), 10); // used for semver only - } catch (e) {/**/} - } - return false; -} - -function modInstall(install) { - child_process.execSync("npm --silent install " + (typeof install === "string" ? install : install.join(" ")), { - cwd: __dirname, - stdio: "ignore" - }); -} - -exports.setup = function() { - var pkg = require(path.join(__dirname, "..", "package.json")); - var version = pkg.dependencies["semver"] || pkg.devDependencies["semver"]; - if (!modExists("semver", version)) { - process.stderr.write("installing semver@" + version + "\n"); - modInstall("semver@" + version); - } - semver = require("semver"); // used from now on for version comparison - var install = []; - pkg.cliDependencies.forEach(function(name) { - if (name === "semver") - return; - version = pkg.dependencies[name] || pkg.devDependencies[name]; - if (!modExists(name, version)) { - process.stderr.write("installing " + name + "@" + version + "\n"); - install.push(name + "@" + version); - } - }); - require("../scripts/postinstall"); // emit postinstall warning, if any - if (!install.length) - return; - modInstall(install); -}; - exports.wrap = function(OUTPUT, options) { var name = options.wrap || "default"; var wrap; diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 37898b6d2..bf4ff454c 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -4,9 +4,6 @@ var path = require("path"), fs = require("fs"), pkg = require(path.join(__dirname, "..", "package.json")); -// ensure that there is a node_modules folder for cli dependencies -try { fs.mkdirSync(path.join(__dirname, "..", "cli", "node_modules")); } catch (e) {/**/} - // check version scheme used by dependents if (!pkg.versionScheme) return;