Skip to content

Commit 57a2de4

Browse files
Merge pull request #728 from lakatostamas/fix/bin-extensions
fix(bin): extension detection (#724)
2 parents 556a333 + 8dc5999 commit 57a2de4

File tree

11 files changed

+107
-3
lines changed

11 files changed

+107
-3
lines changed

bin/convert-argv.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,17 @@ module.exports = function(...args) {
6969
const configArgList = Array.isArray(argv.config) ? argv.config : [argv.config];
7070
configFiles = configArgList.map(mapConfigArg);
7171
} else {
72-
const defaultConfigFiles = ["webpack.config", "webpackfile"];
73-
const webpackConfigFileRegExp = `(${defaultConfigFiles.join("|")})(${extensions.join("|")})`;
72+
const defaultConfigFileNames = ["webpack.config", "webpackfile"].join("|");
73+
const webpackConfigFileRegExp = `(${defaultConfigFileNames})(${extensions.join("|")})`;
7474
const pathToWebpackConfig = findup(webpackConfigFileRegExp);
7575

7676
if (pathToWebpackConfig) {
7777
const resolvedPath = path.resolve(pathToWebpackConfig);
78+
const actualConfigFileName = path.basename(resolvedPath);
79+
const ext = actualConfigFileName.replace(new RegExp(defaultConfigFileNames), "");
7880
configFiles.push({
7981
path: resolvedPath,
80-
ext: resolvedPath.split(".").pop()
82+
ext,
8183
});
8284
}
8385
}

package-lock.json

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"rimraf": "^2.6.2",
153153
"schema-utils": "^1.0.0",
154154
"ts-jest": "^23.10.4",
155+
"ts-node": "^7.0.1",
155156
"tslint": "^5.11.0",
156157
"typedoc": "^0.13.0",
157158
"typedoc-plugin-monorepo": "^0.1.0",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["env"]
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "webpack-babel-config";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
3+
const { run } = require("../../../testUtils");
4+
5+
test("webpack-babel-config", () => {
6+
const { code, stdout, stderr } = run(__dirname, [
7+
"--output-filename",
8+
"[name].js",
9+
"--output-chunk-filename",
10+
"[id].chunk.js",
11+
"--target",
12+
"async-node",
13+
]);
14+
expect(code).toBe(0);
15+
expect(stdout).toContain("./index2.js");
16+
expect(stderr).toHaveLength(0);
17+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// eslint-disable-next-line node/no-unsupported-features, node/no-unsupported-features/es-syntax
2+
import path from "path";
3+
4+
const config = {
5+
entry: path.resolve(__dirname, "./index2")
6+
};
7+
8+
// eslint-disable-next-line node/no-unsupported-features, node/no-unsupported-features/es-syntax
9+
export default config;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "webpack-ts-config";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"esModuleInterop": true
4+
}
5+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
3+
const { run } = require("../../../testUtils");
4+
5+
test("webpack-ts-config", () => {
6+
const { code, stdout, stderr } = run(__dirname, [
7+
"--output-filename",
8+
"[name].js",
9+
"--output-chunk-filename",
10+
"[id].chunk.js",
11+
"--target",
12+
"async-node",
13+
]);
14+
expect(code).toBe(0);
15+
expect(stdout).toContain("./index2.js");
16+
expect(stderr).toHaveLength(0);
17+
});

0 commit comments

Comments
 (0)