Skip to content

Commit c5ae324

Browse files
authored
bug #394 Filter --keep-public-path from arguments (fixes #180) (x539)
2 parents c7b30a0 + f68d914 commit c5ae324

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

bin/encore.js

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ if (runtimeConfig.outputJson) {
2929
// remove the command from the input
3030
process.argv.splice(2, 1);
3131

32+
// remove arguments not supported by webpack/-dev-server
33+
const encoreOnlyArguments = new Set(['--keep-public-path']);
34+
process.argv = process.argv.filter(arg => !encoreOnlyArguments.has(arg));
35+
3236
if (!runtimeConfig.isValidCommand) {
3337
if (runtimeConfig.command) {
3438
console.log(chalk.bgRed.white(`Invalid command "${runtimeConfig.command}"`));

test/bin/encore.js

+28
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,32 @@ module.exports = Encore.getWebpackConfig();
114114
done();
115115
});
116116
});
117+
118+
it('Smoke test using the --keep-public-path option', (done) => {
119+
testSetup.emptyTmpDir();
120+
const testDir = testSetup.createTestAppDir();
121+
122+
fs.writeFileSync(
123+
path.join(testDir, 'webpack.config.js'),
124+
`
125+
const Encore = require('../../index.js');
126+
Encore
127+
.setOutputPath('build/')
128+
.setPublicPath('/build')
129+
.addEntry('main', './js/no_require')
130+
;
131+
132+
module.exports = Encore.getWebpackConfig();
133+
`
134+
);
135+
136+
const binPath = path.resolve(__dirname, '../', '../', 'bin', 'encore.js');
137+
exec(`node ${binPath} dev --keep-public-path --context=${testDir}`, { cwd: testDir }, (err, stdout, stderr) => {
138+
if (err) {
139+
throw new Error(`Error executing encore: ${err} ${stderr} ${stdout}`);
140+
}
141+
142+
done();
143+
});
144+
});
117145
});

0 commit comments

Comments
 (0)