Skip to content

Commit

Permalink
feat: support custom npm clients (options.npm) (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcxfs1991 authored and michael-ciniawsky committed Jun 30, 2017
1 parent ed1edd6 commit 3168f63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ plugins: [
peerDependencies: true,
// Reduce amount of console logging
quiet: false,
// npm command used inside company, yarn is not supported yet
npm: 'tnpm'
});
],
```
Expand Down
9 changes: 7 additions & 2 deletions src/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ var util = require("util");
var EXTERNAL = /^\w[a-z\-0-9\.]+$/; // Match "react", "path", "fs", "lodash.random", etc.
var PEERS = /UNMET PEER DEPENDENCY ([a-z\-0-9\.]+)@(.+)/gm;

var defaultOptions = { dev: false, peerDependencies: true, quiet: false };
var defaultOptions = {
dev: false,
peerDependencies: true,
quiet: false,
npm: 'npm',
};
var erroneous = [];

function normalizeBabelPlugin(plugin, prefix) {
Expand Down Expand Up @@ -145,7 +150,7 @@ module.exports.install = function install(deps, options) {
});

// Ignore input, capture output, show errors
var output = spawn.sync("npm", args, {
var output = spawn.sync(options.npm, args, {
stdio: ["ignore", "pipe", "inherit"]
});

Expand Down
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ NpmInstallPlugin.prototype.resolve = function(resolver, result, callback) {
);
}

if (major === "2") {
if (major === "2" || major === "3") {
return this.compiler.resolvers[resolver].resolve(
result.context || {},
result.path,
Expand Down
1 change: 1 addition & 0 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe("plugin", function() {
dev: false,
peerDependencies: true,
quiet: false,
npm: 'npm',
};

this.plugin = new Plugin(this.options);
Expand Down

0 comments on commit 3168f63

Please sign in to comment.