Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 3168f63

Browse files
lcxfs1991michael-ciniawsky
authored andcommitted
feat: support custom npm clients (options.npm) (#113)
1 parent ed1edd6 commit 3168f63

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ plugins: [
4848
peerDependencies: true,
4949
// Reduce amount of console logging
5050
quiet: false,
51+
// npm command used inside company, yarn is not supported yet
52+
npm: 'tnpm'
5153
});
5254
],
5355
```

src/installer.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ var util = require("util");
77
var EXTERNAL = /^\w[a-z\-0-9\.]+$/; // Match "react", "path", "fs", "lodash.random", etc.
88
var PEERS = /UNMET PEER DEPENDENCY ([a-z\-0-9\.]+)@(.+)/gm;
99

10-
var defaultOptions = { dev: false, peerDependencies: true, quiet: false };
10+
var defaultOptions = {
11+
dev: false,
12+
peerDependencies: true,
13+
quiet: false,
14+
npm: 'npm',
15+
};
1116
var erroneous = [];
1217

1318
function normalizeBabelPlugin(plugin, prefix) {
@@ -145,7 +150,7 @@ module.exports.install = function install(deps, options) {
145150
});
146151

147152
// Ignore input, capture output, show errors
148-
var output = spawn.sync("npm", args, {
153+
var output = spawn.sync(options.npm, args, {
149154
stdio: ["ignore", "pipe", "inherit"]
150155
});
151156

src/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ NpmInstallPlugin.prototype.resolve = function(resolver, result, callback) {
136136
);
137137
}
138138

139-
if (major === "2") {
139+
if (major === "2" || major === "3") {
140140
return this.compiler.resolvers[resolver].resolve(
141141
result.context || {},
142142
result.path,

test/plugin.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe("plugin", function() {
4141
dev: false,
4242
peerDependencies: true,
4343
quiet: false,
44+
npm: 'npm',
4445
};
4546

4647
this.plugin = new Plugin(this.options);

0 commit comments

Comments
 (0)