From d9a64c0a145c46d8611f3fc8295c70e4f32fdc6d Mon Sep 17 00:00:00 2001 From: Axetroy Date: Sun, 28 Apr 2019 01:14:56 +0800 Subject: [PATCH] fs: fix ensureLink broken (#360) Fixes #358 --- fs/ensure_link.ts | 6 +++--- fs/ensure_link_test.ts | 12 +++++++----- fs/test.ts | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/ensure_link.ts b/fs/ensure_link.ts index a1f512c7cd..707f2bee99 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 { 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 8d14f34ec0..593df5702b 100644 --- a/fs/ensure_link_test.ts +++ b/fs/ensure_link_test.ts @@ -18,7 +18,7 @@ test(async function ensureLinkIfItNotExist(): Promise { const linkFile = path.join(destDir, "link.txt"); await assertThrowsAsync( - (): Promise => { + async (): Promise => { await ensureLink(testFile, linkFile); } ); @@ -147,8 +147,9 @@ test(async function ensureLinkDirectoryIfItExist(): Promise { async (): Promise => { 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 9f6b4827b9..90e3c4688d 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";