Skip to content

Commit e6534ae

Browse files
authored
chore: lint blocking calls (#180)
1 parent 180037b commit e6534ae

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

deno.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
},
1010
"lint": {
1111
"rules": {
12-
"exclude": ["ban-types", "no-explicit-any", "no-this-alias"]
12+
"exclude": ["ban-types", "no-explicit-any", "no-this-alias"],
13+
"include": [
14+
"no-sync-fn-in-async-fn"
15+
]
1316
}
1417
},
1518
"exclude": [

mod.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ Deno.test("cp test2", async () => {
12741274
await withTempDir(async (dir) => {
12751275
await $`mkdir -p a/d1`;
12761276
await $`mkdir -p a/d2`;
1277-
Deno.createSync("a/d1/f").close();
1277+
await Deno.create("a/d1/f").then((f) => f.close());
12781278
await $`cp a/d1/f a/d2`;
12791279
assert(dir.join("a/d2/f").existsSync());
12801280
});
@@ -1430,12 +1430,12 @@ Deno.test("cd", () => {
14301430

14311431
Deno.test("cat", async () => {
14321432
await withTempDir(async () => {
1433-
Deno.writeTextFileSync("hello", "hello world");
1433+
await Deno.writeTextFile("hello", "hello world");
14341434
assertEquals(
14351435
await $`cat hello`.text(),
14361436
"hello world",
14371437
);
1438-
Deno.writeTextFileSync("hello2", "hello world2");
1438+
await Deno.writeTextFile("hello2", "hello world2");
14391439
assertEquals(
14401440
await $`cat hello hello2`.text(),
14411441
"hello worldhello world2",

src/commands/cat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function executeCat(context: CommandContext) {
3939
} else {
4040
let file;
4141
try {
42-
file = Deno.openSync(pathUtils.join(context.cwd, path), { read: true });
42+
file = await Deno.open(pathUtils.join(context.cwd, path), { read: true });
4343
while (true) {
4444
// NOTE: rust supports cancellation here
4545
const size = file.readSync(buf);

src/deps.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export { serve } from "https://deno.land/[email protected]/http/server.ts";
1818
*/
1919
export async function withTempDir(action: (path: PathRef) => Promise<void> | void) {
2020
const originalDirPath = Deno.cwd();
21-
const dirPath = Deno.makeTempDirSync();
21+
const dirPath = await Deno.makeTempDir();
2222
Deno.chdir(dirPath);
2323
try {
2424
await action(createPathRef(dirPath).resolve());

src/request.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Deno.test("$.request", (t) => {
108108
});
109109

110110
step("pipeToPath", async () => {
111-
const testFilePath = Deno.makeTempFileSync();
111+
const testFilePath = await Deno.makeTempFile();
112112
const originDir = Deno.cwd();
113113
try {
114114
{
@@ -121,7 +121,7 @@ Deno.test("$.request", (t) => {
121121
}
122122
{
123123
// test default path
124-
Deno.chdir(Deno.makeTempDirSync()); // change path just to not download to the current dir
124+
Deno.chdir(await Deno.makeTempDir()); // change path just to not download to the current dir
125125
const downloadedFilePath = await new RequestBuilder()
126126
.url(new URL("/text-file", serverUrl))
127127
.showProgress()
@@ -151,7 +151,7 @@ Deno.test("$.request", (t) => {
151151
}
152152
{
153153
// test downloading to a directory
154-
const tempDir = Deno.makeTempDirSync();
154+
const tempDir = await Deno.makeTempDir();
155155
const downloadedFilePath = await new RequestBuilder()
156156
.url(new URL("/text-file", serverUrl))
157157
.showProgress()
@@ -162,7 +162,7 @@ Deno.test("$.request", (t) => {
162162
} finally {
163163
try {
164164
Deno.chdir(originDir);
165-
Deno.removeSync(testFilePath);
165+
await Deno.remove(testFilePath);
166166
} catch {
167167
// do nothing
168168
}

0 commit comments

Comments
 (0)