Skip to content

Commit

Permalink
tests: --node-env
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Feb 2, 2021
1 parent b685e17 commit b811c54
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/webpack-cli/lib/webpack-cli.js
Expand Up @@ -1658,6 +1658,7 @@ class WebpackCLI {

// apply process.env.NODE_ENV with the help of --node-env
this.applyNodeEnv(options);

config = await this.applyOptions(config, options);
config = await this.applyCLIPlugin(config, options);

Expand Down
14 changes: 10 additions & 4 deletions test/node-env/node-env.test.js
@@ -1,7 +1,13 @@
'use strict';
//const { resolve } = require('path');
//const { run } = require('../utils/test-utils');

//describe('--node-env flag', () => {
const { run } = require('../utils/test-utils');

//});
describe('--node-env flag', () => {
it('should set process.env.NODE_ENV', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--node-env', 'production']);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("mode: 'production'");
});
});
5 changes: 4 additions & 1 deletion test/node-env/webpack.config.js
@@ -1,3 +1,6 @@
const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin');

module.exports = {
mode: 'development',
mode: process.env.NODE_ENV,
plugins: [new WebpackCLITestPlugin()],
};

0 comments on commit b811c54

Please sign in to comment.