Skip to content

Commit 9a859d4

Browse files
committed
bug #114 Fixing a bug with webpack 3.4.0 with extra arg as an entry (weaverryan)
This PR was squashed before being merged into the master branch (closes #114). Discussion ---------- Fixing a bug with webpack 3.4.0 with extra arg as an entry Fixes #112 The updated way avoids triggering the "singleton" behavior or yargs. This is important so that later, when webpack uses yargs, it uses the updated `process.argv` (because we remove our extra "command" argument so that webpack doesn't see it). I'm not sure exactly which dep/commit caused the issue, but this a more proper solution anyways. Also added a smoke test for the encore binary. Commits ------- 2b7ca5b Fixing a bug with webpack 3.4.0 with extra arg as an entry
2 parents 52cff12 + 2b7ca5b commit 9a859d4

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

bin/encore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const context = require('../lib/context');
1515
const chalk = require('chalk');
1616

1717
const runtimeConfig = parseRuntime(
18-
require('yargs').argv,
18+
require('yargs/yargs')(process.argv.slice(2)).argv,
1919
process.cwd()
2020
);
2121
context.runtimeConfig = runtimeConfig;

test/bin/encore.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of the Symfony package.
3+
*
4+
* (c) Fabien Potencier <[email protected]>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
'use strict';
11+
12+
const chai = require('chai');
13+
chai.use(require('chai-fs'));
14+
const path = require('path');
15+
const testSetup = require('../../lib/test/setup');
16+
const fs = require('fs-extra');
17+
const exec = require('child_process').exec;
18+
19+
describe('bin/encore.js', function() {
20+
// being functional tests, these can take quite long
21+
this.timeout(8000);
22+
23+
it('Basic smoke test', (done) => {
24+
testSetup.emptyTmpDir();
25+
const testDir = testSetup.createTestAppDir();
26+
27+
fs.writeFileSync(
28+
path.join(testDir, 'webpack.config.js'),
29+
`
30+
const Encore = require('../../index.js');
31+
Encore
32+
.setOutputPath('build/')
33+
.setPublicPath('/build')
34+
.addEntry('main', './js/no_require')
35+
;
36+
37+
module.exports = Encore.getWebpackConfig();
38+
`
39+
);
40+
41+
const binPath = path.resolve(__dirname, '../', '../', 'bin', 'encore.js');
42+
exec(`node ${binPath} dev --context=${testDir}`, { cwd: testDir }, (err, stdout, stderr) => {
43+
if (err) {
44+
throw new Error(`Error executing encore: ${err} ${stderr} ${stdout}`);
45+
}
46+
47+
done();
48+
});
49+
});
50+
});

0 commit comments

Comments
 (0)