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: add env var to skip local import #2546

Merged
merged 2 commits into from Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/webpack-cli/bin/cli.js
Expand Up @@ -12,9 +12,11 @@ const importLocal = require('import-local');
const runCLI = require('../lib/bootstrap');
const utils = require('../lib/utils');

// Prefer the local installation of `webpack-cli`
if (importLocal(__filename)) {
return;
if (!process.env.WEBPACK_CLI_SKIP_IMPORT_LOCAL) {
// Prefer the local installation of `webpack-cli`
if (importLocal(__filename)) {
return;
}
}

process.title = 'webpack';
Expand Down
22 changes: 22 additions & 0 deletions test/build/import-local/import-local.test.js
@@ -0,0 +1,22 @@
'use strict';

const { run } = require('../../utils/test-utils');

const importLocalMock = jest.fn();
jest.setMock('import-local', importLocalMock);

describe('import local', () => {
beforeEach(() => {
importLocalMock.mockClear();
});
it('should skip import local when supplied', () => {
const { exitCode, stderr, stdout } = run(__dirname, [], {
env: { WEBPACK_CLI_SKIP_IMPORT_LOCAL: true },
});
console.log({ exitCode, stderr, stdout });
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove it

Copy link
Member Author

Choose a reason for hiding this comment

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

hm done

expect(importLocalMock).toHaveBeenCalledTimes(0);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
});
});
Empty file.