From 260684489c14f5438044e53c3efa6bbc479e61c7 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 16 Feb 2020 14:19:21 +1300 Subject: [PATCH] chore: replace `TSymlinkType` with `symlink.Type` from `fs` --- src/promises.ts | 7 +++---- src/volume.ts | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/promises.ts b/src/promises.ts index 64222d4c..8a2de8fc 100644 --- a/src/promises.ts +++ b/src/promises.ts @@ -4,7 +4,6 @@ import { TMode, TFlags, TFlagsCopy, - TSymlinkType, TTime, IOptions, IAppendFileOptions, @@ -18,7 +17,7 @@ import { import Stats from './Stats'; import Dirent from './Dirent'; import { TDataOut } from './encoding'; -import { PathLike } from 'fs'; +import { PathLike, symlink } from 'fs'; function promisify( vol: Volume, @@ -88,7 +87,7 @@ export interface IPromisesAPI { rename(oldPath: PathLike, newPath: PathLike): Promise; rmdir(path: PathLike): Promise; stat(path: PathLike, options?: IStatOptions): Promise; - symlink(target: PathLike, path: PathLike, type?: TSymlinkType): Promise; + symlink(target: PathLike, path: PathLike, type?: symlink.Type): Promise; truncate(path: PathLike, len?: number): Promise; unlink(path: PathLike): Promise; utimes(path: PathLike, atime: TTime, mtime: TTime): Promise; @@ -250,7 +249,7 @@ export default function createPromisesApi(vol: Volume): null | IPromisesAPI { return promisify(vol, 'stat')(path, options); }, - symlink(target: PathLike, path: PathLike, type?: TSymlinkType): Promise { + symlink(target: PathLike, path: PathLike, type?: symlink.Type): Promise { return promisify(vol, 'symlink')(target, path, type); }, diff --git a/src/volume.ts b/src/volume.ts index df9a50b3..1d3a15f8 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -1,5 +1,5 @@ import * as pathModule from 'path'; -import { PathLike } from 'fs'; +import { PathLike, symlink } from 'fs'; import { Node, Link, File } from './node'; import Stats, { TStatNumber } from './Stats'; import Dirent from './Dirent'; @@ -61,7 +61,6 @@ export type TTime = number | string | Date; export type TCallback = (error?: IError | null, data?: TData) => void; // type TCallbackWrite = (err?: IError, bytesWritten?: number, source?: Buffer) => void; // type TCallbackWriteStr = (err?: IError, written?: number, str?: string) => void; -export type TSymlinkType = 'file' | 'dir' | 'junction'; // ---------------------------------------- Constants @@ -1414,15 +1413,15 @@ export class Volume { } // `type` argument works only on Windows. - symlinkSync(target: PathLike, path: PathLike, type?: TSymlinkType) { + symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type) { const targetFilename = pathToFilename(target); const pathFilename = pathToFilename(path); this.symlinkBase(targetFilename, pathFilename); } symlink(target: PathLike, path: PathLike, callback: TCallback); - symlink(target: PathLike, path: PathLike, type: TSymlinkType, callback: TCallback); - symlink(target: PathLike, path: PathLike, a: TSymlinkType | TCallback, b?: TCallback) { + symlink(target: PathLike, path: PathLike, type: symlink.Type, callback: TCallback); + symlink(target: PathLike, path: PathLike, a: symlink.Type | TCallback, b?: TCallback) { const callback: TCallback = validateCallback(typeof a === 'function' ? a : b); const targetFilename = pathToFilename(target); const pathFilename = pathToFilename(path);