Skip to content

Commit de8f06a

Browse files
committed
fix: use tmp's sync API
1 parent c46b932 commit de8f06a

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/client/common/platform/fs-temp.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ import * as tmp from 'tmp';
55
import { ITempFileSystem, TemporaryFile } from './types';
66

77
interface IRawTempFS {
8-
// TODO (https://github.com/microsoft/vscode/issues/84517)
9-
// This functionality has been requested for the
10-
// VS Code FS API (vscode.workspace.fs.*).
11-
file(
12-
config: tmp.Options,
13-
14-
callback?: (err: any, path: string, fd: number, cleanupCallback: () => void) => void,
15-
): void;
8+
fileSync(config?: tmp.Options): tmp.SynchrounousResult;
169
}
1710

1811
// Operations related to temporary files and directories.
@@ -35,14 +28,13 @@ export class TemporaryFileSystem implements ITempFileSystem {
3528
mode,
3629
};
3730
return new Promise<TemporaryFile>((resolve, reject) => {
38-
this.raw.file(opts, (err, filename, _fd, cleanUp) => {
39-
if (err) {
40-
return reject(err);
41-
}
42-
resolve({
43-
filePath: filename,
44-
dispose: cleanUp,
45-
});
31+
const { name, removeCallback } = this.raw.fileSync(opts);
32+
if (!name) {
33+
return reject(new Error('Failed to create temp file'));
34+
}
35+
resolve({
36+
filePath: name,
37+
dispose: removeCallback,
4638
});
4739
});
4840
}

0 commit comments

Comments
 (0)