Skip to content

Commit

Permalink
refactor: optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
断刀 committed Apr 4, 2024
1 parent 6846a36 commit 08b36e1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/typed-jest/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { lilconfig } from "lilconfig";
import { hideBin } from "yargs/helpers";
import yargs from "yargs/yargs";

const requireResolve = createRequire(import.meta.url).resolve;

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const tsJestPath = createRequire(import.meta.url).resolve("ts-jest");

/**
* @param {unknown} configPath
Expand All @@ -20,6 +18,7 @@ async function getFileConfig(configPath) {
const config = await import(path.resolve(process.cwd(), configPath));
return config.default ?? config;
} else {
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const config = await lilconfig("jest").search(path.join(__dirname, ".."));
return config?.config ?? {};
}
Expand All @@ -33,7 +32,7 @@ export async function getConfigs() {
* @type {([string]|[string,string])[]}
*/
const defaultConfigs = [
["transform", `{"^.+\\\\.tsx?$":"${requireResolve("ts-jest")}"}`],
["transform", `{"^.+\\\\.tsx?$":"${tsJestPath}"}`],
["passWithNoTests"],
["collectCoverageFrom", "**/src/**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}"], // TODO collecting coverage from src folder is not the best choice.
];
Expand Down

0 comments on commit 08b36e1

Please sign in to comment.