Merge pull request #25975 from KSXGitHub/symlink-type-union

Set type of symlink parameter `type` to a union of `"file" | "dir" | "junction" | undefined | null`
This commit is contained in:
Armando Aguirre
2018-06-06 13:18:17 -07:00
committed by GitHub
8 changed files with 28 additions and 19 deletions
@@ -18,7 +18,7 @@ let buffer: Buffer;
declare const modeNum: number;
declare const modeStr: string;
declare const encoding: string;
declare const type: string;
declare const symlinkType: "file" | "dir" | "junction";
declare const flags: string;
declare const srcpath: string;
declare const dstpath: string;
@@ -117,8 +117,8 @@ stats = fs.lstatSync(path);
stats = fs.fstatSync(fd);
fs.link(srcpath, dstpath, errorCallback);
fs.linkSync(srcpath, dstpath);
fs.symlink(srcpath, dstpath, type, errorCallback);
fs.symlinkSync(srcpath, dstpath, type);
fs.symlink(srcpath, dstpath, symlinkType, errorCallback);
fs.symlinkSync(srcpath, dstpath, symlinkType);
fs.readlink(path, (err: Error, linkString: string) => {
});
fs.realpath(path, (err: Error, resolvedPath: string) => {
+2 -2
View File
@@ -90,7 +90,7 @@ export function fstatSync(fd: number): Stats;
export function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void;
export function linkSync(srcpath: string, dstpath: string): void;
export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void;
export function symlinkSync(srcpath: string, dstpath: string, type?: string): void;
export function symlinkSync(srcpath: string, dstpath: string, type?: fs.symlink.Type): void;
export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void;
export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void;
export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void;
@@ -189,7 +189,7 @@ export function statAsync(path: string): Promise<Stats>;
export function lstatAsync(path: string): Promise<Stats>;
export function fstatAsync(fd: number): Promise<Stats>;
export function linkAsync(srcpath: string, dstpath: string): Promise<void>;
export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise<void>;
export function symlinkAsync(srcpath: string, dstpath: string, type?: fs.symlink.Type): Promise<void>;
export function readlinkAsync(path: string): Promise<string>;
export function realpathAsync(path: string, cache?: string): Promise<string>;
export function unlinkAsync(path: string): Promise<void>;
@@ -20,7 +20,7 @@ let buffer: Buffer;
declare const modeNum: number;
declare const modeStr: string;
declare const encoding: string;
declare const type: string;
declare const symlinkType: "file" | "dir" | "junction";
declare const flags: string;
declare const srcpath: string;
declare const dstpath: string;
@@ -117,8 +117,8 @@ stats = fs.lstatSync(path);
stats = fs.fstatSync(fd);
fs.link(srcpath, dstpath, errorCallback);
fs.linkSync(srcpath, dstpath);
fs.symlink(srcpath, dstpath, type, errorCallback);
fs.symlinkSync(srcpath, dstpath, type);
fs.symlink(srcpath, dstpath, symlinkType, errorCallback);
fs.symlinkSync(srcpath, dstpath, symlinkType);
fs.readlink(path, (err: Error, linkString: string) => {
});
fs.realpath(path, (err: Error, resolvedPath: string) => {
+3 -2
View File
@@ -7,9 +7,10 @@
/// <reference types="node" />
import * as stream from 'stream';
import { Stats } from 'fs';
import * as fs from 'fs';
import * as Promise from 'bluebird';
import { CopyFilter, CopyOptions, ReadOptions, WriteOptions, MoveOptions } from 'fs-extra';
import Stats = fs.Stats;
export * from 'fs-extra';
@@ -53,7 +54,7 @@ export function statAsync(path: string): Promise<Stats>;
export function lstatAsync(path: string): Promise<Stats>;
export function fstatAsync(fd: number): Promise<Stats>;
export function linkAsync(srcpath: string, dstpath: string): Promise<void>;
export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise<void>;
export function symlinkAsync(srcpath: string, dstpath: string, type?: fs.symlink.Type): Promise<void>;
export function readlinkAsync(path: string): Promise<string>;
export function realpathAsync(path: string, cache?: { [path: string]: string }): Promise<string>;
export function unlinkAsync(path: string): Promise<void>;
+5 -3
View File
@@ -10,7 +10,8 @@
/// <reference types="node" />
import { Stats } from "fs";
import * as fs from "fs";
import Stats = fs.Stats;
export * from "fs";
@@ -206,8 +207,9 @@ export function rmdir(path: string | Buffer): Promise<void>;
export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function stat(path: string | Buffer): Promise<Stats>;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise<void>;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: fs.symlink.Type | undefined, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: fs.symlink.Type): Promise<void>;
export function truncate(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
export function truncate(path: string | Buffer, len: number, callback: (err: NodeJS.ErrnoException) => void): void;
+4 -2
View File
@@ -3470,7 +3470,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
/**
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
@@ -3489,6 +3489,8 @@ declare module "fs" {
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
export type Type = "dir" | "file" | "junction";
}
/**
@@ -3498,7 +3500,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void;
export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
/**
* Asynchronous readlink(2) - read value of a symbolic link.
+4 -2
View File
@@ -3371,7 +3371,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
/**
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
@@ -3390,6 +3390,8 @@ declare module "fs" {
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
export type Type = "dir" | "file" | "junction";
}
/**
@@ -3399,7 +3401,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void;
export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
/**
* Asynchronous readlink(2) - read value of a symbolic link.
+4 -2
View File
@@ -3453,7 +3453,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlink(target: PathLike, path: PathLike, type: string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
export function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
/**
* Asynchronous symlink(2) - Create a new symbolic link to an existing file.
@@ -3472,6 +3472,8 @@ declare module "fs" {
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function __promisify__(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
export type Type = "dir" | "file" | "junction";
}
/**
@@ -3481,7 +3483,7 @@ declare module "fs" {
* @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
* When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
*/
export function symlinkSync(target: PathLike, path: PathLike, type?: string | null): void;
export function symlinkSync(target: PathLike, path: PathLike, type?: symlink.Type | null): void;
/**
* Asynchronous readlink(2) - read value of a symbolic link.