Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add --config-name flag (#1753)
- Loading branch information
Showing
8 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
const { run } = require('../utils/test-utils'); | ||
const { stat } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
describe('--config-name flag', () => { | ||
it('should select only the config whose name is passed with --config-name', (done) => { | ||
const { stderr, stdout } = run(__dirname, ['--config-name', 'first'], false); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain('Child first'); | ||
expect(stdout).not.toContain('Child second'); | ||
expect(stdout).not.toContain('Child third'); | ||
|
||
stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should work with multiple values for --config-name', (done) => { | ||
const { stderr, stdout } = run(__dirname, ['--config-name', 'first', '--config-name', 'third'], false); | ||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain('Child first'); | ||
expect(stdout).not.toContain('Child second'); | ||
expect(stdout).toContain('Child third'); | ||
|
||
stat(resolve(__dirname, './dist/dist-first.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
stat(resolve(__dirname, './dist/dist-third.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should log error if invalid config name is provided', () => { | ||
const { stderr, stdout } = run(__dirname, ['--config-name', 'test'], false); | ||
expect(stderr).toContain('Configuration with name "test" was not found.'); | ||
expect(stdout).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('first config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('second config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('third config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = [ | ||
{ | ||
output: { | ||
filename: './dist-first.js', | ||
}, | ||
name: 'first', | ||
entry: './src/first.js', | ||
mode: 'development', | ||
}, | ||
{ | ||
output: { | ||
filename: './dist-second.js', | ||
}, | ||
name: 'second', | ||
entry: './src/second.js', | ||
mode: 'production', | ||
}, | ||
{ | ||
output: { | ||
filename: './dist-third.js', | ||
}, | ||
name: 'third', | ||
entry: './src/third.js', | ||
mode: 'none', | ||
}, | ||
]; |