summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2018-09-14 12:30:43 -0700
committerRyan Dahl <ry@tinyclouds.org>2018-09-14 12:30:43 -0700
commit662e57b20adc7bbb7037c116f8f72678017db94e (patch)
tree8c6f4377c4bcaceb59220af438e8dda139f98b6a /js
parent66c09de967b6bf91cb9c6b2d915ab42efa59c349 (diff)
[fs] Enable mode for `mkdir` on unix (#746)
Diffstat (limited to 'js')
-rw-r--r--js/mkdir_test.ts9
-rw-r--r--js/stat.ts3
2 files changed, 11 insertions, 1 deletions
diff --git a/js/mkdir_test.ts b/js/mkdir_test.ts
index ed275bd36..4f82401dc 100644
--- a/js/mkdir_test.ts
+++ b/js/mkdir_test.ts
@@ -9,6 +9,15 @@ testPerm({ write: true }, function mkdirSyncSuccess() {
assert(pathInfo.isDirectory());
});
+testPerm({ write: true }, function mkdirSyncMode() {
+ const path = deno.makeTempDirSync() + "/dir/subdir";
+ deno.mkdirSync(path, 0o755); // no perm for x
+ const pathInfo = deno.statSync(path);
+ if (pathInfo.mode !== null) { // Skip windows
+ assertEqual(pathInfo.mode & 0o777, 0o755);
+ }
+});
+
testPerm({ write: false }, function mkdirSyncPerm() {
let err;
try {
diff --git a/js/stat.ts b/js/stat.ts
index 3193794a5..434841ec2 100644
--- a/js/stat.ts
+++ b/js/stat.ts
@@ -51,7 +51,8 @@ export class FileInfo {
this.modified = modified ? modified : null;
this.accessed = accessed ? accessed : null;
this.created = created ? created : null;
- this.mode = mode >= 0 ? mode : null; // null if invalid mode (Windows)
+ // null if invalid mode (Windows)
+ this.mode = mode >= 0 ? mode & 0o7777 : null;
}
/**