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(runtime): add truncate and truncateSync methods to Deno.File #10130

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Merge branch 'main' into feat-add-truncate-methods-to-file
  • Loading branch information
bartlomieju committed Apr 12, 2021
commit c0ccd5b25001c81020b3cfa3b69ed9ab254c2fcf
32 changes: 32 additions & 0 deletions cli/tests/unit/file_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,35 @@ unitTest(
await Deno.remove(filename);
},
);

unitTest({ perms: { read: true } }, function fileStatSyncSuccess(): void {
const file = Deno.openSync("README.md");
const fileInfo = file.statSync();
assert(fileInfo.isFile);
assert(!fileInfo.isSymlink);
assert(!fileInfo.isDirectory);
assert(fileInfo.size);
assert(fileInfo.atime);
assert(fileInfo.mtime);
// The `birthtime` field is not available on Linux before kernel version 4.11.
assert(fileInfo.birthtime || Deno.build.os === "linux");

file.close();
});

unitTest({ perms: { read: true } }, async function fileStatSuccess(): Promise<
void
> {
const file = await Deno.open("README.md");
const fileInfo = await file.stat();
assert(fileInfo.isFile);
assert(!fileInfo.isSymlink);
assert(!fileInfo.isDirectory);
assert(fileInfo.size);
assert(fileInfo.atime);
assert(fileInfo.mtime);
// The `birthtime` field is not available on Linux before kernel version 4.11.
assert(fileInfo.birthtime || Deno.build.os === "linux");

file.close();
});
2 changes: 1 addition & 1 deletion runtime/js/40_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
((window) => {
const core = window.Deno.core;
const { read, readSync, write, writeSync } = window.__bootstrap.io;
const { ftruncate, ftruncateSync } = window.__bootstrap.fs;
const { ftruncate, ftruncateSync, fstat, fstatSync } = window.__bootstrap.fs;
const { pathFromURL } = window.__bootstrap.util;

function seekSync(
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.