Skip to content

Commit

Permalink
chore: replace TSymlinkType with symlink.Type from fs
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Feb 16, 2020
1 parent a383112 commit 2606844
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/promises.ts
Expand Up @@ -4,7 +4,6 @@ import {
TMode,
TFlags,
TFlagsCopy,
TSymlinkType,
TTime,
IOptions,
IAppendFileOptions,
Expand All @@ -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,
Expand Down Expand Up @@ -88,7 +87,7 @@ export interface IPromisesAPI {
rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
rmdir(path: PathLike): Promise<void>;
stat(path: PathLike, options?: IStatOptions): Promise<Stats>;
symlink(target: PathLike, path: PathLike, type?: TSymlinkType): Promise<void>;
symlink(target: PathLike, path: PathLike, type?: symlink.Type): Promise<void>;
truncate(path: PathLike, len?: number): Promise<void>;
unlink(path: PathLike): Promise<void>;
utimes(path: PathLike, atime: TTime, mtime: TTime): Promise<void>;
Expand Down Expand Up @@ -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<void> {
symlink(target: PathLike, path: PathLike, type?: symlink.Type): Promise<void> {
return promisify(vol, 'symlink')(target, path, type);
},

Expand Down
9 changes: 4 additions & 5 deletions 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';
Expand Down Expand Up @@ -61,7 +61,6 @@ export type TTime = number | string | Date;
export type TCallback<TData> = (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

Expand Down Expand Up @@ -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<void>);
symlink(target: PathLike, path: PathLike, type: TSymlinkType, callback: TCallback<void>);
symlink(target: PathLike, path: PathLike, a: TSymlinkType | TCallback<void>, b?: TCallback<void>) {
symlink(target: PathLike, path: PathLike, type: symlink.Type, callback: TCallback<void>);
symlink(target: PathLike, path: PathLike, a: symlink.Type | TCallback<void>, b?: TCallback<void>) {
const callback: TCallback<void> = validateCallback(typeof a === 'function' ? a : b);
const targetFilename = pathToFilename(target);
const pathFilename = pathToFilename(path);
Expand Down

0 comments on commit 2606844

Please sign in to comment.