Last active
June 4, 2020 13:40
-
-
Save rjoydip-zz/6e934463d8e304792f1fc81241183610 to your computer and use it in GitHub Desktop.
Issue on statSync while importing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hasEnv(): boolean { | |
try { | |
return Deno.statSync(".env").isFile; | |
} catch (_) { | |
return false; | |
} | |
} | |
async function createEnv(): Promise<void> { | |
const dockerenv = await Deno.open(".env", { | |
write: true, | |
create: true, | |
}); | |
await Deno.writeAll(dockerenv, new TextEncoder().encode("")); | |
Deno.close(dockerenv.rid); | |
} | |
async function removeEnv(): Promise<void> { | |
await Deno.remove(".env"); | |
} | |
console.log(hasEnv()); | |
await createEnv(); | |
console.log(hasEnv()); | |
await removeEnv(); | |
console.log(hasEnv()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { hasEnv, createEnv, removeEnv } from "./import.ts"; | |
console.log(hasEnv()); | |
await createEnv(); | |
console.log(hasEnv()); | |
await removeEnv(); | |
console.log(hasEnv()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function hasEnv(): boolean { | |
try { | |
return Deno.statSync(".dockerenv").isFile; | |
} catch (_) { | |
return false; | |
} | |
} | |
export async function createEnv(): Promise<void> { | |
const dockerenv = await Deno.open(".env", { | |
write: true, | |
create: true, | |
}); | |
await Deno.writeAll(dockerenv, new TextEncoder().encode("")); | |
Deno.close(dockerenv.rid); | |
} | |
export async function removeEnv(): Promise<void> { | |
await Deno.remove(".env"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment