Skip to content

Commit

Permalink
fix(remix): ensure typescript is available during workspace gen #298 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Jun 20, 2023
1 parent 12f5493 commit f8d658e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/remix/src/utils/testing-config-utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { stripIndents, type Tree } from '@nx/devkit';
import { ensureTypescript } from '@nx/js/src/utils/typescript/ensure-typescript';
import { tsquery } from '@phenomnomnominal/tsquery';

let tsModule: typeof import('typescript');

export function updateViteTestSetup(
tree: Tree,
pathToViteConfig: string,
pathToTestSetup: string
) {
if (!tsModule) {
tsModule = ensureTypescript();
}
const fileContents = tree.read(pathToViteConfig, 'utf-8');

const ast = tsquery.ast(fileContents);
Expand Down Expand Up @@ -52,6 +58,9 @@ export function updateJestTestSetup(
pathToJestConfig: string,
pathToTestSetup: string
) {
if (!tsModule) {
tsModule = ensureTypescript();
}
const fileContents = tree.read(pathToJestConfig, 'utf-8');

const ast = tsquery.ast(fileContents);
Expand Down Expand Up @@ -95,6 +104,9 @@ export function updateViteTestIncludes(
pathToViteConfig: string,
includesString: string
) {
if (!tsModule) {
tsModule = ensureTypescript();
}
const fileContents = tree.read(pathToViteConfig, 'utf-8');

const ast = tsquery.ast(fileContents);
Expand Down

0 comments on commit f8d658e

Please sign in to comment.