-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Deno to run without
--unstable
. Add a test that that's possible.
While there, fix Deno (and our test suite) to connect to a TCP socket, as Deno doesn't work well with Unix sockets on macOS.
- Loading branch information
Showing
6 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import {process} from "https://deno.land/[email protected]/node/process.ts"; | ||
import {Buffer} from "https://deno.land/[email protected]/node/buffer.ts"; | ||
import * as crypto from "https://deno.land/[email protected]/node/crypto.ts"; | ||
import * as fs from "https://deno.land/[email protected]/node/fs.ts"; | ||
import {Sha256, HmacSha256} from "https://deno.land/[email protected]/hash/sha256.ts"; | ||
import path from "https://deno.land/[email protected]/node/path.ts"; | ||
import EventEmitter from "https://deno.land/[email protected]/node/events.ts"; | ||
import util from "https://deno.land/[email protected]/node/util.ts"; | ||
|
||
export {Buffer, path, process, util, fs, crypto}; | ||
export {Buffer, path, process, util, crypto}; | ||
|
||
export function readFileUtf8Sync(path: string): string { | ||
return Deno.readTextFileSync(path); | ||
} | ||
|
||
export async function randomBytes(size: number): Promise<Buffer> { | ||
const buf = new Uint8Array(size); | ||
|
@@ -47,6 +50,28 @@ export function hrTime(): number { | |
return performance.now(); | ||
} | ||
|
||
// TODO: replace this with | ||
// `import * as fs from "https://deno.land/[email protected]/node/fs.ts";` | ||
// when the 'fs' compat module does not require '--unstable' flag. | ||
export namespace fs { | ||
export function existsSync(fn: string | URL): boolean { | ||
fn = fn instanceof URL ? path.fromFileUrl(fn) : fn; | ||
try { | ||
Deno.lstatSync(fn); | ||
return true; | ||
} catch (err) { | ||
if (err instanceof Deno.errors.NotFound) { | ||
return false; | ||
} | ||
throw err; | ||
} | ||
} | ||
|
||
export function realpathSync(path: string): string { | ||
return Deno.realPathSync(path); | ||
} | ||
} | ||
|
||
// TODO: when 'net.Socket' is implemented in deno node compatibility library | ||
// replace this (https://github.com/denoland/deno_std/pull/694) | ||
export namespace net { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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