Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 8f44e4e

Browse files
author
Rusty Key
committed
use platform’s tmp dir
1 parent 7000de8 commit 8f44e4e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/formatters/ocaml.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { execSync } from "child_process";
22
import * as fs from "fs";
3+
import * as os from "os";
4+
import * as path from "path";
35
import { v4 as uuidv4 } from "uuid";
46
import * as vscode from "vscode";
57
import { getFormatter, getFullTextRange } from "./utils";
@@ -18,7 +20,7 @@ export function register() {
1820
if (!formatter) return [];
1921

2022
if (textEditor) {
21-
const tempFileName = `/tmp/vscode-reasonml-${uuidv4()}.ml`;
23+
const tempFileName = path.join(os.tmpdir(), `vscode-reasonml-ocamlformat-${uuidv4()}.ml`);
2224
fs.writeFileSync(tempFileName, textEditor.document.getText(), "utf8");
2325
try {
2426
const filePath = textEditor.document.fileName;

src/formatters/reason.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { execSync } from "child_process";
22
import * as fs from "fs";
3+
import * as os from "os";
4+
import * as path from "path";
35
import { v4 as uuidv4 } from "uuid";
46
import * as vscode from "vscode";
57
import { getFormatter, getFullTextRange } from "./utils";
@@ -17,7 +19,7 @@ export function register() {
1719
if (!formatter) return [];
1820

1921
if (textEditor) {
20-
const tempFileName = `/tmp/vscode-refmt-${uuidv4()}.re`;
22+
const tempFileName = path.join(os.tmpdir(), `vscode-reasonml-refmt-${uuidv4()}.ml`);
2123
fs.writeFileSync(tempFileName, textEditor.document.getText(), "utf8");
2224
try {
2325
const formattedText = execSync(`${formatter} ${tempFileName}`).toString();

0 commit comments

Comments
 (0)