From 52ef0f1056eca09391b89699bb6bc9a442bab605 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 17 May 2018 15:58:55 +0700 Subject: [PATCH 1/4] Ignore shrinkwrap.yaml --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c8e25cec8d..ac63b6f6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ npm-debug.log # yarn yarn.lock + +# pnpm +shrinkwrap.yaml From 80987f14289ed45458c4ef2bcad5ab8baaeae151 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 24 May 2018 00:41:03 +0700 Subject: [PATCH 2/4] Set type of symlink parameter 'type' to a union --- types/fs-extra/index.d.ts | 8 +++++--- types/node/index.d.ts | 6 ++++-- types/node/v8/index.d.ts | 6 ++++-- types/node/v9/index.d.ts | 6 ++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index adf236955b..153b285ae1 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -10,7 +10,8 @@ /// -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; export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; export function stat(path: string | Buffer): Promise; -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; +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; 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; diff --git a/types/node/index.d.ts b/types/node/index.d.ts index d964a41c43..14e4bf4a64 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -3461,7 +3461,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. @@ -3480,6 +3480,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; + + export type Type = "dir" | "file" | "junction"; } /** @@ -3489,7 +3491,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. diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index 27014e0cb0..8a27035ecc 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -3368,7 +3368,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. @@ -3387,6 +3387,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; + + export type Type = "dir" | "file" | "junction"; } /** @@ -3396,7 +3398,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. diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 014fd9bac1..3fffc0a576 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -3450,7 +3450,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. @@ -3469,6 +3469,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; + + export type Type = "dir" | "file" | "junction"; } /** @@ -3478,7 +3480,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. From 813279ba32db4f5434d5e30bc5f61d1b68dd40b5 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Thu, 24 May 2018 09:29:15 +0700 Subject: [PATCH 3/4] Update fs-extra-promise and fs-extra-promise-es6 * Edit `symlinkAsync` and `symlinkSync` * Fix test --- types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts | 6 +++--- types/fs-extra-promise-es6/index.d.ts | 4 ++-- types/fs-extra-promise/fs-extra-promise-tests.ts | 6 +++--- types/fs-extra-promise/index.d.ts | 5 +++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts index bdff193912..9e076ff8eb 100644 --- a/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts +++ b/types/fs-extra-promise-es6/fs-extra-promise-es6-tests.ts @@ -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) => { diff --git a/types/fs-extra-promise-es6/index.d.ts b/types/fs-extra-promise-es6/index.d.ts index 2b7dacd108..125fa51679 100644 --- a/types/fs-extra-promise-es6/index.d.ts +++ b/types/fs-extra-promise-es6/index.d.ts @@ -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; export function lstatAsync(path: string): Promise; export function fstatAsync(fd: number): Promise; export function linkAsync(srcpath: string, dstpath: string): Promise; -export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: fs.symlink.Type): Promise; export function readlinkAsync(path: string): Promise; export function realpathAsync(path: string, cache?: string): Promise; export function unlinkAsync(path: string): Promise; diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index 61549a55ad..441e62b884 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -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) => { diff --git a/types/fs-extra-promise/index.d.ts b/types/fs-extra-promise/index.d.ts index b4ac5be133..a7222b9d5d 100644 --- a/types/fs-extra-promise/index.d.ts +++ b/types/fs-extra-promise/index.d.ts @@ -7,9 +7,10 @@ /// 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; export function lstatAsync(path: string): Promise; export function fstatAsync(fd: number): Promise; export function linkAsync(srcpath: string, dstpath: string): Promise; -export function symlinkAsync(srcpath: string, dstpath: string, type?: string): Promise; +export function symlinkAsync(srcpath: string, dstpath: string, type?: fs.symlink.Type): Promise; export function readlinkAsync(path: string): Promise; export function realpathAsync(path: string, cache?: { [path: string]: string }): Promise; export function unlinkAsync(path: string): Promise; From 47667055bbb80097f2a43bed68d5e022d6e7fa6a Mon Sep 17 00:00:00 2001 From: khai96_ Date: Fri, 1 Jun 2018 10:45:09 +0700 Subject: [PATCH 4/4] Restore .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index ac63b6f6b5..c8e25cec8d 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,3 @@ npm-debug.log # yarn yarn.lock - -# pnpm -shrinkwrap.yaml