forked from web-infra-dev/rspack
-
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: ensure webpack.config.js exist in configCase (web-infra-dev#4837)
- Loading branch information
Showing
10 changed files
with
33 additions
and
4 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...uiltin-swc-loader/issue-4597/src/index.js → ...es/builtin-swc-loader/issue-4597/index.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
File renamed without changes.
File renamed without changes.
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 @@ | ||
import path from "path"; | ||
import fs from "fs"; | ||
|
||
// TODO: It's better to use `Promise.all` | ||
function configFileExist(dir: string, config: "webpack" | "rspack") { | ||
const files = ["js", "ts", "mjs", "mts"].map( | ||
ext => `${config}.config.${ext}` | ||
); | ||
return files.some(file => { | ||
const p = path.resolve(dir, file); | ||
return fs.existsSync(p) && fs.lstatSync(p).isFile(); | ||
}); | ||
} | ||
|
||
export function ensureWebpackConfigExist(testCaseDir: string) { | ||
const exist = configFileExist(testCaseDir, "webpack"); | ||
if (!exist) { | ||
throw Error(`not found webpack.config.js in ${testCaseDir}`); | ||
} | ||
} | ||
|
||
export function ensureRspackConfigNotExist(testCaseDir: string) { | ||
const exist = configFileExist(testCaseDir, "rspack"); | ||
if (exist) { | ||
throw Error(`rspack config file should not exist in ${testCaseDir}`); | ||
} | ||
} |