forked from webpack/webpack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fixed mergin conflict webpack#2
- Loading branch information
Showing
19 changed files
with
205 additions
and
31 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
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,53 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const execa = require('execa'); | ||
const { sync: spawnSync } = execa; | ||
|
||
const { run } = require('../utils/test-utils'); | ||
|
||
describe('global flag', () => { | ||
it('warns if there are no arguments to flag', () => { | ||
const { stderr } = run(__dirname, ['--global']); | ||
expect(stderr).toContain('Argument to global flag is none'); | ||
}); | ||
|
||
it('warns if there are no value for key', () => { | ||
const { stderr } = run(__dirname, ['--global', 'myVar']); | ||
expect(stderr).toContain('Argument to global flag expected a key/value pair'); | ||
}); | ||
|
||
it('is able inject one variable to global scope', () => { | ||
const { stderr } = run(__dirname, ['--global', 'myVar', './global1.js']); | ||
expect(stderr).toBe(''); | ||
const executable = path.join(__dirname, './bin/bundle.js'); | ||
const bundledScript = spawnSync('node', [executable]); | ||
expect(bundledScript.stdout).toEqual('myVar ./global1.js'); | ||
}); | ||
|
||
it('is able inject multiple variables to global scope', () => { | ||
const { stderr } = run(__dirname, ['--global', 'myVar', './global1.js', '--global', 'myVar2', './global2.js']); | ||
expect(stderr).toBe(''); | ||
const executable = path.join(__dirname, './bin/bundle.js'); | ||
const bundledScript = spawnSync('node', [executable]); | ||
expect(bundledScript.stdout).toEqual('myVar ./global1.js\nmyVar ./global2.js'); | ||
}); | ||
|
||
it('understands = syntax', () => { | ||
const { stderr } = run(__dirname, ['--global', 'myVar', './global1.js', '--global', 'myVar2=./global2.js']); | ||
expect(stderr).toBe(''); | ||
const executable = path.join(__dirname, './bin/bundle.js'); | ||
const bundledScript = spawnSync('node', [executable]); | ||
expect(bundledScript.stdout).toEqual('myVar ./global1.js\nmyVar ./global2.js'); | ||
}); | ||
|
||
it('warns on multiple flags that are inconsistent', () => { | ||
const result = run(__dirname, ['--global', 'myVar', './global1.js', '--global', 'myVar2']); | ||
// eslint-disable-next-line | ||
expect(result.stderr).toContain("Found unmatching value for global flag key 'myVar2'"); | ||
|
||
const result2 = run(__dirname, ['--global', 'myVar', './global1.js', '--global', 'myVar2=']); | ||
// eslint-disable-next-line | ||
expect(result2.stderr).toContain("Found unmatching value for global flag key 'myVar2'"); | ||
}); | ||
}); |
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 @@ | ||
module.exports = 'myVar ./global1.js'; |
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 @@ | ||
module.exports = 'myVar ./global2.js'; |
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,5 @@ | ||
console.log(myVar); | ||
|
||
try { | ||
console.log(myVar2); | ||
} catch(e) {} |
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,3 @@ | ||
module.exports = { | ||
entry: './some_entry.js', | ||
}; |
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,5 @@ | ||
module.exports = { | ||
output: { | ||
filename: 'merged.js', | ||
}, | ||
}; |
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,18 @@ | ||
'use strict'; | ||
|
||
const { stat } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
const { run } = require('../../utils/test-utils'); | ||
|
||
describe('merge flag configuration', () => { | ||
it('merges two configurations together', done => { | ||
const { stderr } = run(__dirname, ['--config', './1.js', '--merge', './2.js'], false); | ||
expect(stderr).toBe(''); | ||
stat(resolve(__dirname, './dist/merged.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
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('yass'); |
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,3 @@ | ||
module.exports = { | ||
entry: './some_other_entry.js', | ||
}; |
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,27 @@ | ||
'use strict'; | ||
|
||
const { stat } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
const { run } = require('../../utils/test-utils'); | ||
|
||
describe('merge flag defaults', () => { | ||
it('merges a default webpack.base.config with default config lookup', done => { | ||
const { stderr } = run(__dirname, ['-m'], false); | ||
expect(stderr).toBe(''); | ||
stat(resolve(__dirname, './dist/default.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
it('merges a configuraiton file with default base config', done => { | ||
const { stderr } = run(__dirname, ['-c', './1.js'], false); | ||
expect(stderr).toBe(''); | ||
stat(resolve(__dirname, './dist/bundle.js'), (err, stats) => { | ||
expect(err).toBe(null); | ||
expect(stats.isFile()).toBe(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
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('<3'); |
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('moo'); |
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,5 @@ | ||
module.exports = { | ||
output: { | ||
filename: 'default.js', | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = { | ||
entry: './some_entry.js', | ||
}; |