Skip to content

Commit

Permalink
remove cliDependencies installation
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorcode committed Aug 7, 2019
1 parent 642fdea commit 8f9eba3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 56 deletions.
2 changes: 0 additions & 2 deletions cli/pbjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
5 changes: 1 addition & 4 deletions cli/pbts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
48 changes: 1 addition & 47 deletions cli/util.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8f9eba3

Please sign in to comment.