Skip to content

Commit

Permalink
fix: Use cosmiconfigSync to work around segfault in tests
Browse files Browse the repository at this point in the history
Consistently running into a segfault coming from Node as a result of
cosmiconfig attempting to run a dynamic import on the listed .js config
file caused by:

nodejs/node#35889
jestjs/jest#11438

Using cosmiconfigSync to workaround this which will fall back to using a
synchronous require() call.
  • Loading branch information
ryanwilsonperkin committed Sep 22, 2023
1 parent ef0b43a commit 8cb6bd4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cosmiconfig } from 'cosmiconfig';
import { cosmiconfigSync } from 'cosmiconfig';
import { ProcessedResult } from './process';
import { readJson, writeJson } from './fs';
import { CliArguments, Context, PackageJson } from './index';
Expand Down Expand Up @@ -136,8 +136,8 @@ export async function getConfig(args?: CliArguments): Promise<Config> {
return cachedConfig;
}

const cosmiconfigResult = await cosmiconfig('unimported').search();
const configFile = (cosmiconfigResult?.config ?? {}) as Partial<UnimportedConfig>;
const cosmiconfigResult = cosmiconfigSync('unimported').search();
const configFile = cosmiconfigResult?.config as Partial<UnimportedConfig>;

const unimportedPkg = await readPkgUp({ cwd: __dirname });

Expand Down

0 comments on commit 8cb6bd4

Please sign in to comment.