Skip to content

Commit

Permalink
fix(core): write file directly instead of using `fs-extra.outputFileS…
Browse files Browse the repository at this point in the history
…ync` (#18129)

(cherry picked from commit 187842e)
  • Loading branch information
Cammisuli authored and FrozenPandaz committed Jul 17, 2023
1 parent bd9e749 commit 371ba7a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/nx/src/utils/testing/temp-fs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'path';
import { basename, dirname, join } from 'path';
import { tmpdir } from 'os';
import {
mkdtempSync,
Expand All @@ -8,9 +8,10 @@ import {
emptyDirSync,
outputFileSync,
unlinkSync,
mkdirpSync,
} from 'fs-extra';
import { joinPathFragments } from '../path';
import { appendFileSync, writeFileSync, renameSync } from 'fs';
import { appendFileSync, writeFileSync, renameSync, existsSync } from 'fs';

type NestedFiles = {
[fileName: string]: string;
Expand Down Expand Up @@ -44,7 +45,11 @@ export class TempFs {
}

createFileSync(filePath: string, content: string) {
outputFileSync(joinPathFragments(this.tempDir, filePath), content);
let dir = joinPathFragments(this.tempDir, dirname(filePath));
if (!existsSync(dir)) {
mkdirpSync(dir);
}
writeFileSync(joinPathFragments(this.tempDir, filePath), content);
}

async readFile(filePath: string): Promise<string> {
Expand Down

0 comments on commit 371ba7a

Please sign in to comment.