Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support custom npm clients (options.npm) #113

Merged
merged 4 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "npm-install-webpack-plugin",
"version": "4.0.4",
"version": "4.0.5",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this, it is the maintainer/releaser responsibility to do and we have a standard process for this in place already :)

"description": "Webpack loader to automatically npm install & save dependencies.",
"main": "index.js",
"engines": {
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