fix(core): write file directly instead of using fs-extra.outputFileSync (#18129)
This commit is contained in:
parent
2fa248d4f5
commit
187842e14c
@ -1,4 +1,4 @@
|
|||||||
import { join } from 'path';
|
import { basename, dirname, join } from 'path';
|
||||||
import { tmpdir } from 'os';
|
import { tmpdir } from 'os';
|
||||||
import {
|
import {
|
||||||
mkdtempSync,
|
mkdtempSync,
|
||||||
@ -8,9 +8,10 @@ import {
|
|||||||
emptyDirSync,
|
emptyDirSync,
|
||||||
outputFileSync,
|
outputFileSync,
|
||||||
unlinkSync,
|
unlinkSync,
|
||||||
|
mkdirpSync,
|
||||||
} from 'fs-extra';
|
} from 'fs-extra';
|
||||||
import { joinPathFragments } from '../path';
|
import { joinPathFragments } from '../path';
|
||||||
import { appendFileSync, writeFileSync, renameSync } from 'fs';
|
import { appendFileSync, writeFileSync, renameSync, existsSync } from 'fs';
|
||||||
|
|
||||||
type NestedFiles = {
|
type NestedFiles = {
|
||||||
[fileName: string]: string;
|
[fileName: string]: string;
|
||||||
@ -44,7 +45,11 @@ export class TempFs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createFileSync(filePath: string, content: string) {
|
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> {
|
async readFile(filePath: string): Promise<string> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user