mirror of
https://github.com/denoland/deno.git
synced 2025-01-14 10:01:51 -05:00
parent
ec70367e5b
commit
d9a64c0a14
3 changed files with 11 additions and 8 deletions
|
@ -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}'`
|
||||
);
|
||||
|
|
|
@ -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 });
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue