Skip to content

Commit

Permalink
Merge pull request #728 from lakatostamas/fix/bin-extensions
Browse files Browse the repository at this point in the history
fix(bin): extension detection (#724)
  • Loading branch information
evenstensberg committed Jan 7, 2019
2 parents 556a333 + 8dc5999 commit 57a2de4
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/convert-argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@ module.exports = function(...args) {
const configArgList = Array.isArray(argv.config) ? argv.config : [argv.config];
configFiles = configArgList.map(mapConfigArg);
} else {
const defaultConfigFiles = ["webpack.config", "webpackfile"];
const webpackConfigFileRegExp = `(${defaultConfigFiles.join("|")})(${extensions.join("|")})`;
const defaultConfigFileNames = ["webpack.config", "webpackfile"].join("|");
const webpackConfigFileRegExp = `(${defaultConfigFileNames})(${extensions.join("|")})`;
const pathToWebpackConfig = findup(webpackConfigFileRegExp);

if (pathToWebpackConfig) {
const resolvedPath = path.resolve(pathToWebpackConfig);
const actualConfigFileName = path.basename(resolvedPath);
const ext = actualConfigFileName.replace(new RegExp(defaultConfigFileNames), "");
configFiles.push({
path: resolvedPath,
ext: resolvedPath.split(".").pop()
ext,
});
}
}
Expand Down
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"rimraf": "^2.6.2",
"schema-utils": "^1.0.0",
"ts-jest": "^23.10.4",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typedoc": "^0.13.0",
"typedoc-plugin-monorepo": "^0.1.0",
Expand Down
3 changes: 3 additions & 0 deletions test/binCases/config-location/webpack-babel-config/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "webpack-babel-config";
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";

const { run } = require("../../../testUtils");

test("webpack-babel-config", () => {
const { code, stdout, stderr } = run(__dirname, [
"--output-filename",
"[name].js",
"--output-chunk-filename",
"[id].chunk.js",
"--target",
"async-node",
]);
expect(code).toBe(0);
expect(stdout).toContain("./index2.js");
expect(stderr).toHaveLength(0);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// eslint-disable-next-line node/no-unsupported-features, node/no-unsupported-features/es-syntax
import path from "path";

const config = {
entry: path.resolve(__dirname, "./index2")
};

// eslint-disable-next-line node/no-unsupported-features, node/no-unsupported-features/es-syntax
export default config;
1 change: 1 addition & 0 deletions test/binCases/config-location/webpack-ts-config/index2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "webpack-ts-config";
5 changes: 5 additions & 0 deletions test/binCases/config-location/webpack-ts-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";

const { run } = require("../../../testUtils");

test("webpack-ts-config", () => {
const { code, stdout, stderr } = run(__dirname, [
"--output-filename",
"[name].js",
"--output-chunk-filename",
"[id].chunk.js",
"--target",
"async-node",
]);
expect(code).toBe(0);
expect(stdout).toContain("./index2.js");
expect(stderr).toHaveLength(0);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import path from "path";
import webpack from "webpack";

const config: webpack.Configuration = {
entry: path.resolve(__dirname, "./index2"),
};

export default config;

0 comments on commit 57a2de4

Please sign in to comment.