diff options
author | Luca Casonato <hello@lcas.dev> | 2021-11-22 16:53:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 16:53:58 +0100 |
commit | 3cc724c9bae94c2f79dd4a902782a66f688a1e61 (patch) | |
tree | 2f3feda1880c499c989aaf9e017ea4602ea60ea1 /runtime/js | |
parent | 429c773a2e729a56a551a0b645fd5cbf7ef0fe99 (diff) |
fix(runtime): support reading /proc using readFile (#12839)
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/40_read_file.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/js/40_read_file.js b/runtime/js/40_read_file.js index 53ac9b08a..5e90b523a 100644 --- a/runtime/js/40_read_file.js +++ b/runtime/js/40_read_file.js @@ -4,13 +4,18 @@ ((window) => { const core = window.Deno.core; const { open, openSync } = window.__bootstrap.files; - const { readAllSyncSized, readAllInnerSized } = window.__bootstrap.io; + const { readAllSync, readAll, readAllSyncSized, readAllInnerSized } = + window.__bootstrap.io; function readFileSync(path) { const file = openSync(path); try { const { size } = file.statSync(); - return readAllSyncSized(file, size); + if (size === 0) { + return readAllSync(file); + } else { + return readAllSyncSized(file, size); + } } finally { file.close(); } @@ -20,7 +25,11 @@ const file = await open(path); try { const { size } = await file.stat(); - return await readAllInnerSized(file, size, options); + if (size === 0) { + return await readAll(file); + } else { + return await readAllInnerSized(file, size, options); + } } finally { file.close(); } |