Skip to content

Commit 4c60ad4

Browse files
committed
Use rootDir instead of cwd
1 parent fd7184f commit 4c60ad4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

heft-plugins/heft-jest-plugin/src/transformers/StringMockTransformer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const isWindows: boolean = process.platform === 'win32';
1313
*/
1414
export class StringMockTransformer implements SyncTransformer {
1515
public process(sourceText: string, sourcePath: string, options: TransformOptions): TransformedSource {
16-
const relativePath: string = relative(options.config.cwd, sourcePath);
16+
// heft-jest-plugin enforces that config.rootDir will always be the project root folder.
17+
const relativePath: string = relative(options.config.rootDir, sourcePath);
1718
const normalizedRelativePath: string = isWindows ? relativePath.replace(/\\/g, '/') : relativePath;
1819
// For a file called "myImage.png", this will generate a JS module that exports the slash-normalized relative
1920
// path from the current working directory to "myImage.png"

0 commit comments

Comments
 (0)