summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxetroy <troy450409405@gmail.com>2019-04-28 01:14:56 +0800
committerRyan Dahl <ry@tinyclouds.org>2019-04-27 10:14:56 -0700
commit1059133b2146cbad7b17c9358747c5c3ce7cd8e5 (patch)
tree9645915d10a1dd94b83a4e50e555cd650b9d7ad4
parent7021391d38dd15bb3cedf5ea71cef0b14edc1c45 (diff)
fs: fix ensureLink broken (denoland/deno_std#360)
Fixes denoland/deno_std#358 Original: https://github.com/denoland/deno_std/commit/d9a64c0a145c46d8611f3fc8295c70e4f32fdc6d
-rw-r--r--fs/ensure_link.ts6
-rw-r--r--fs/ensure_link_test.ts12
-rw-r--r--fs/test.ts1
3 files changed, 11 insertions, 8 deletions
diff --git a/fs/ensure_link.ts b/fs/ensure_link.ts
index a1f512c7c..707f2bee9 100644
--- a/fs/ensure_link.ts
+++ b/fs/ensure_link.ts
@@ -2,7 +2,7 @@
import * as path from "./path/mod.ts";
import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
import { exists, existsSync } from "./exists.ts";
-import { PathType, getFileInfoType } from "./utils.ts";
+import { getFileInfoType } from "./utils.ts";
/**
* Ensures that the hard link exists.
@@ -15,7 +15,7 @@ export async function ensureLink(src: string, dest: string): Promise<void> {
if (await exists(dest)) {
const destStatInfo = await Deno.lstat(dest);
const destFilePathType = getFileInfoType(destStatInfo);
- if (destFilePathType !== PathType.file) {
+ if (destFilePathType !== "file") {
throw new Error(
`Ensure path exists, expected 'file', got '${destFilePathType}'`
);
@@ -39,7 +39,7 @@ export function ensureLinkSync(src: string, dest: string): void {
if (existsSync(dest)) {
const destStatInfo = Deno.lstatSync(dest);
const destFilePathType = getFileInfoType(destStatInfo);
- if (destFilePathType !== PathType.file) {
+ if (destFilePathType !== "file") {
throw new Error(
`Ensure path exists, expected 'file', got '${destFilePathType}'`
);
diff --git a/fs/ensure_link_test.ts b/fs/ensure_link_test.ts
index 8d14f34ec..593df5702 100644
--- a/fs/ensure_link_test.ts
+++ b/fs/ensure_link_test.ts
@@ -18,7 +18,7 @@ test(async function ensureLinkIfItNotExist(): Promise<void> {
const linkFile = path.join(destDir, "link.txt");
await assertThrowsAsync(
- (): Promise<void> => {
+ async (): Promise<void> => {
await ensureLink(testFile, linkFile);
}
);
@@ -147,8 +147,9 @@ test(async function ensureLinkDirectoryIfItExist(): Promise<void> {
async (): Promise<void> => {
await ensureLink(testDir, linkDir);
},
- Deno.DenoError,
- "Operation not permitted (os error 1)"
+ Deno.DenoError
+ // "Operation not permitted (os error 1)" // throw an local matching test
+ // "Access is denied. (os error 5)" // throw in CI
);
Deno.removeSync(testDir, { recursive: true });
@@ -166,8 +167,9 @@ test(function ensureLinkSyncDirectoryIfItExist(): void {
(): void => {
ensureLinkSync(testDir, linkDir);
},
- Deno.DenoError,
- "Operation not permitted (os error 1)"
+ Deno.DenoError
+ // "Operation not permitted (os error 1)" // throw an local matching test
+ // "Access is denied. (os error 5)" // throw in CI
);
Deno.removeSync(testDir, { recursive: true });
diff --git a/fs/test.ts b/fs/test.ts
index 9f6b4827b..90e3c4688 100644
--- a/fs/test.ts
+++ b/fs/test.ts
@@ -9,6 +9,7 @@ import "./empty_dir_test.ts";
import "./ensure_dir_test.ts";
import "./ensure_file_test.ts";
import "./ensure_symlink_test.ts";
+import "./ensure_link_test.ts";
import "./move_test.ts";
import "./read_json_test.ts";
import "./write_json_test.ts";