Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lint blocking calls #180

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
},
"lint": {
"rules": {
"exclude": ["ban-types", "no-explicit-any", "no-this-alias"]
"exclude": ["ban-types", "no-explicit-any", "no-this-alias"],
"include": [
"no-sync-fn-in-async-fn"
]
}
},
"exclude": [
Expand Down
6 changes: 3 additions & 3 deletions mod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ Deno.test("cp test2", async () => {
await withTempDir(async (dir) => {
await $`mkdir -p a/d1`;
await $`mkdir -p a/d2`;
Deno.createSync("a/d1/f").close();
await Deno.create("a/d1/f").then((f) => f.close());
await $`cp a/d1/f a/d2`;
assert(dir.join("a/d2/f").existsSync());
});
Expand Down Expand Up @@ -1430,12 +1430,12 @@ Deno.test("cd", () => {

Deno.test("cat", async () => {
await withTempDir(async () => {
Deno.writeTextFileSync("hello", "hello world");
await Deno.writeTextFile("hello", "hello world");
assertEquals(
await $`cat hello`.text(),
"hello world",
);
Deno.writeTextFileSync("hello2", "hello world2");
await Deno.writeTextFile("hello2", "hello world2");
assertEquals(
await $`cat hello hello2`.text(),
"hello worldhello world2",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function executeCat(context: CommandContext) {
} else {
let file;
try {
file = Deno.openSync(pathUtils.join(context.cwd, path), { read: true });
file = await Deno.open(pathUtils.join(context.cwd, path), { read: true });
while (true) {
// NOTE: rust supports cancellation here
const size = file.readSync(buf);
Expand Down
2 changes: 1 addition & 1 deletion src/deps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export { serve } from "https://deno.land/[email protected]/http/server.ts";
*/
export async function withTempDir(action: (path: PathRef) => Promise<void> | void) {
const originalDirPath = Deno.cwd();
const dirPath = Deno.makeTempDirSync();
const dirPath = await Deno.makeTempDir();
Deno.chdir(dirPath);
try {
await action(createPathRef(dirPath).resolve());
Expand Down
8 changes: 4 additions & 4 deletions src/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Deno.test("$.request", (t) => {
});

step("pipeToPath", async () => {
const testFilePath = Deno.makeTempFileSync();
const testFilePath = await Deno.makeTempFile();
const originDir = Deno.cwd();
try {
{
Expand All @@ -121,7 +121,7 @@ Deno.test("$.request", (t) => {
}
{
// test default path
Deno.chdir(Deno.makeTempDirSync()); // change path just to not download to the current dir
Deno.chdir(await Deno.makeTempDir()); // change path just to not download to the current dir
const downloadedFilePath = await new RequestBuilder()
.url(new URL("/text-file", serverUrl))
.showProgress()
Expand Down Expand Up @@ -151,7 +151,7 @@ Deno.test("$.request", (t) => {
}
{
// test downloading to a directory
const tempDir = Deno.makeTempDirSync();
const tempDir = await Deno.makeTempDir();
const downloadedFilePath = await new RequestBuilder()
.url(new URL("/text-file", serverUrl))
.showProgress()
Expand All @@ -162,7 +162,7 @@ Deno.test("$.request", (t) => {
} finally {
try {
Deno.chdir(originDir);
Deno.removeSync(testFilePath);
await Deno.remove(testFilePath);
} catch {
// do nothing
}
Expand Down