fix(copy): Add JSDoc, use File

This commit is contained in:
Florian Keller
2019-01-25 10:20:44 +01:00
parent 7c13736555
commit 112e4216d7

59
types/copy/index.d.ts vendored
View File

@@ -7,10 +7,41 @@
import File = require('vinyl');
declare namespace copy {
function each(files: string[], dir: string, options: Options, callback: Callback): void;
function each(files: string[], dir: string, callback: Callback): void;
function one(pattern: string | object, dir: string, options: Options, callback: Callback): void;
function one(pattern: string | object, dir: string, callback: Callback): void;
/**
* Copy an array of files to the given destination `directory`, with
* `options` and callback function that exposes `err` and the array of
* vinyl files that are created by the copy operation.
*
* ```js
* copy.each(['foo.txt', 'bar.txt', 'baz.txt'], 'dist', function(err, files) {
* // exposes the vinyl `files` created when the files are copied
* });
* ```
* @param `files` Filepaths or vinyl files.
* @param `dir` Destination directory
* @param `options` or callback function
* @param `cb` Callback function if no options are specified
*/
function each(files: string[] | File[], dir: string, options: Options, cb: Callback): void;
function each(files: string[] | File[], dir: string, cb: Callback): void;
/**
* Copy a single `file` to the given `dest` directory, using
* the specified options and callback function.
*
* ```js
* copy.one('foo.txt', 'dist', function(err, file) {
* if (err) throw err;
* // exposes the vinyl `file` that is created when the file is copied
* });
* ```
* @param `file` Filepath or vinyl file
* @param `dir` Destination directory
* @param `options` or callback function
* @param `cb` Callback function if no options are specified
*/
function one(pattern: string | File, dir: string, options: Options, cb: Callback): void;
function one(pattern: string | File, dir: string, cb: Callback): void;
type Callback = (error: Error | null, files?: File[]) => void;
@@ -20,12 +51,28 @@ declare namespace copy {
}
}
/**
* Copy a filepath, vinyl file, array of files, or glob of files to the
* given destination `directory`, with `options` and callback function that
* exposes `err` and the array of vinyl files that are created by the copy
* operation.
*
* ```js
* copy('*.js', 'dist', function(err, file) {
* // exposes the vinyl `file` created when the file is copied
* });
* ```
* @param `patterns` Filepath(s), vinyl file(s) or glob of files.
* @param `dir` Destination directory
* @param `options` or callback function
* @param `cb` Callback function if no options are specified
*/
declare function copy(
patterns: string | object | string[],
patterns: string | File | string[] | File[],
dir: string,
options: copy.Options,
callback: copy.Callback,
): void;
declare function copy(patterns: string | object | string[], dir: string, callback: copy.Callback): void;
declare function copy(patterns: string | File | string[] | File[], dir: string, callback: copy.Callback): void;
export = copy;