mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Types for gulp 4.0 (#16121)
* Update index.d.ts * Rewrited types for gulp@4.0. * Updated quotes * Fixed tslint errors. * Fixed some tslint error in test file. * Implemented undertaker in gulp types. * Removed Orchestrator import. * Added backwards compatible type `TaskCallback`. * Fixed `gulp-shell` tests compatibility with gulp@4 types. * Fixed karma tests compatibility with gulp@4 types. * Fixed gulp-rev-replace tests compatibility with gulp@4 types. * Enabled `strictNullChecks` in `gulp` and `undertaker` types. Fixed task function. * Implemented gulp.parallel for `karma` tests. * Implemented gulp.parallel for `gulp-rev-replace` tests. * Implemented gulp.parallel for `gulp-shell` tests.
This commit is contained in:
committed by
Mohamed Hegazy
parent
aba45c2c7f
commit
472244ccbf
@@ -17,21 +17,21 @@ var opt = {
|
||||
distFolder: 'dist'
|
||||
}
|
||||
|
||||
gulp.task("revision", ["dist:css", "dist:js"], () =>
|
||||
gulp.task("revision", gulp.parallel("dist:css", "dist:js", () =>
|
||||
gulp.src(["dist/**/*.css", "dist/**/*.js"])
|
||||
.pipe(rev())
|
||||
.pipe(gulp.dest(opt.distFolder))
|
||||
.pipe(rev.manifest())
|
||||
.pipe(gulp.dest(opt.distFolder))
|
||||
);
|
||||
));
|
||||
|
||||
gulp.task("revreplace", ["revision"], () => {
|
||||
gulp.task("revreplace", gulp.parallel("revision", () => {
|
||||
var manifest = gulp.src("./" + opt.distFolder + "/rev-manifest.json");
|
||||
|
||||
return gulp.src(opt.srcFolder + "/index.html")
|
||||
.pipe(revReplace({manifest: manifest}))
|
||||
.pipe(revReplace({ manifest: manifest }))
|
||||
.pipe(gulp.dest(opt.distFolder));
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
function replaceJsIfMap(filename: string): string {
|
||||
@@ -41,7 +41,7 @@ function replaceJsIfMap(filename: string): string {
|
||||
return filename;
|
||||
}
|
||||
|
||||
gulp.task("revreplace", ["revision"], () => {
|
||||
gulp.task("revreplace", gulp.parallel("revision", () => {
|
||||
var manifest = gulp.src("./" + opt.distFolder + "/rev-manifest.json");
|
||||
|
||||
return gulp.src(opt.distFolder + '**/*.js')
|
||||
@@ -51,4 +51,4 @@ gulp.task("revreplace", ["revision"], () => {
|
||||
modifyReved: replaceJsIfMap
|
||||
}))
|
||||
.pipe(gulp.dest(opt.distFolder));
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
|
||||
import shell = require('gulp-shell');
|
||||
import gulp = require('gulp');
|
||||
|
||||
@@ -29,13 +26,13 @@ var paths: any = {
|
||||
|
||||
gulp.task('test', shell.task('mocha -R spec'));
|
||||
|
||||
gulp.task('coverage', ['test'], shell.task('istanbul cover _mocha -- -R spec'));
|
||||
|
||||
gulp.task('coveralls', ['coverage'], shell.task('cat coverage/lcov.info | coveralls'));
|
||||
gulp.task('coverage', gulp.parallel('test', shell.task('istanbul cover _mocha -- -R spec')));
|
||||
|
||||
gulp.task('coveralls', gulp.parallel('coverage', shell.task('cat coverage/lcov.info | coveralls')));
|
||||
|
||||
gulp.task('lint', shell.task('eslint ' + paths.js.join(' ')));
|
||||
|
||||
gulp.task('default', ['coverage', 'lint']);
|
||||
gulp.task('default', gulp.parallel('coverage', 'lint'));
|
||||
|
||||
gulp.task('watch', function () {
|
||||
gulp.watch(paths.js, ['default'])
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
import gulp = require("gulp");
|
||||
|
||||
var typescript: gulp.GulpPlugin = null; // this would be the TypeScript compiler
|
||||
var jasmine: gulp.GulpPlugin = null; // this would be the jasmine test runner
|
||||
|
||||
gulp.task('compile', function() {
|
||||
gulp.src("**/*.ts")
|
||||
.pipe(typescript())
|
||||
.pipe(gulp.dest('out'))
|
||||
});
|
||||
|
||||
gulp.task('compile2', function(callback: (err?: any) => void) {
|
||||
gulp.src("**/*.ts")
|
||||
.pipe(typescript())
|
||||
.pipe(gulp.dest('out'))
|
||||
.on('end', callback);
|
||||
});
|
||||
|
||||
gulp.task('test', ['compile', 'compile2'], function() {
|
||||
gulp.src("out/test/**/*.js")
|
||||
.pipe(jasmine());
|
||||
});
|
||||
|
||||
gulp.task('default', ['compile', 'test']);
|
||||
|
||||
gulp.task('another', ['with1', 'with2'])
|
||||
.task('some', ['other1', 'other2'], function(cb) { cb(null); })
|
||||
.task('last', function() { });
|
||||
|
||||
|
||||
var opts = {};
|
||||
|
||||
gulp.watch('*.html', 'compile');
|
||||
gulp.watch('*.html', ['compile', 'test']);
|
||||
gulp.watch('*.html', () => {});
|
||||
gulp.watch('*.html', [() => {}, (event) => {}]);
|
||||
gulp.watch('*.html', ['compile', () => {}]);
|
||||
|
||||
gulp.watch('*.html', opts, 'compile');
|
||||
gulp.watch('*.html', opts, ['compile', 'test']);
|
||||
gulp.watch('*.html', opts, () => {});
|
||||
gulp.watch('*.html', opts, [() => {}, (event) => {}]);
|
||||
gulp.watch('*.html', opts, ['compile', () => {}]);
|
||||
|
||||
gulp.watch(['*.html', '*.ts'], 'compile');
|
||||
gulp.watch(['*.html', '*.ts'], ['compile', 'test']);
|
||||
gulp.watch(['*.html', '*.ts'], () => {});
|
||||
gulp.watch(['*.html', '*.ts'], [() => {}, (event) => {}]);
|
||||
gulp.watch(['*.html', '*.ts'], ['compile', () => {}]);
|
||||
|
||||
gulp.watch(['*.html', '*.ts'], opts, 'compile');
|
||||
gulp.watch(['*.html', '*.ts'], opts, ['compile', 'test']);
|
||||
gulp.watch(['*.html', '*.ts'], opts, () => {});
|
||||
gulp.watch(['*.html', '*.ts'], opts, [() => {}, (event) => {}]);
|
||||
gulp.watch(['*.html', '*.ts'], opts, ['compile', () => {}]);
|
||||
|
||||
var watcher = gulp.watch('*.html', event => {
|
||||
console.log('Event type: ' + event.type);
|
||||
console.log('Event path: ' + event.path);
|
||||
});
|
||||
|
||||
gulp.task('serve', ['compile'], () => {
|
||||
gulp.watch(['*.html', '*.ts'], ['compile', () => { return "data"; }]);
|
||||
});
|
||||
|
||||
gulp.start('test', 'compile');
|
||||
Vendored
+54
-349
@@ -1,377 +1,82 @@
|
||||
// Type definitions for Gulp v4.0.x
|
||||
// Type definitions for Gulp 4.0
|
||||
// Project: http://gulpjs.com
|
||||
// Definitions by: Drew Noakes <https://drewnoakes.com>, Juan Arroyave <http://jarroyave.co>
|
||||
// Definitions by: Drew Noakes <https://drewnoakes.com>
|
||||
// Juan Arroyave <http://jarroyave.co>
|
||||
// Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
/// <reference types="orchestrator" />
|
||||
/// <reference types="vinyl" />
|
||||
import * as vfs from "vinyl-fs";
|
||||
import * as chokidar from "chokidar";
|
||||
import * as Undertaker from "undertaker";
|
||||
import * as fs from "fs";
|
||||
import { Duplex } from "stream";
|
||||
|
||||
declare namespace GulpClient {
|
||||
type Globs = string | string[];
|
||||
|
||||
import Orchestrator = require("orchestrator");
|
||||
import VinylFile = require("vinyl");
|
||||
declare type Strings = string|string[];
|
||||
type TaskFunction = Undertaker.TaskFunction;
|
||||
|
||||
declare namespace gulp {
|
||||
interface Gulp extends Orchestrator {
|
||||
task(name: string): never;
|
||||
/**
|
||||
* Define a task
|
||||
* @param name The name of the task.
|
||||
* @param deps An array of task names to be executed and completed before your task will run.
|
||||
* @param fn The function that performs the task's operations. For asynchronous tasks, you need to provide a hint when the task is complete:
|
||||
* <ul>
|
||||
* <li>Take in a callback</li>
|
||||
* <li>Return a stream or a promise</li>
|
||||
* </ul>
|
||||
*/
|
||||
task(name: string, fn?: Orchestrator.TaskFunc): Gulp;
|
||||
/**
|
||||
* Define a task
|
||||
* @param name The name of the task.
|
||||
* @param deps An array of task names to be executed and completed before your task will run.
|
||||
* @param fn The function that performs the task's operations. For asynchronous tasks, you need to provide a hint when the task is complete:
|
||||
* <ul>
|
||||
* <li>Take in a callback</li>
|
||||
* <li>Return a stream or a promise</li>
|
||||
* </ul>
|
||||
*/
|
||||
task(name: string, deps?: string[], fn?: Orchestrator.TaskFunc): Gulp;
|
||||
/**
|
||||
* @deprecated - Now use `TaskFunction`.
|
||||
*/
|
||||
type TaskCallback = TaskFunction;
|
||||
|
||||
interface Gulp extends Undertaker {
|
||||
/**
|
||||
* Takes a number of task names or functions and returns a function of the composed tasks or functions
|
||||
* When the returned function is executed, the tasks or functions will be executed in series,
|
||||
* each waiting for the prior to finish. If an error occurs, execution will stop.
|
||||
* @param A task name, a function or an array of either.
|
||||
* <ul>
|
||||
* <li>Take in a callback</li>
|
||||
* <li>Return a stream or a promise</li>
|
||||
* </ul>
|
||||
*/
|
||||
series: SeriesMethod;
|
||||
/**
|
||||
* Takes a number of task names or functions and returns a function of the composed tasks or functions
|
||||
* When the returned function is executed, the tasks or functions will be executed in parallel,
|
||||
* all being executed at the same time. If an error occurs, all execution will complete.
|
||||
* @param A task name, a function or an array of either.
|
||||
* <ul>
|
||||
* <li>Take in a callback</li>
|
||||
* <li>Return a stream or a promise</li>
|
||||
* </ul>
|
||||
*/
|
||||
parallel: ParallelMethod;
|
||||
/**
|
||||
* Emits files matching provided glob or an array of globs. Returns a stream of Vinyl files that can be piped to plugins.
|
||||
* @param glob Glob or array of globs to read.
|
||||
* @param opt Options to pass to node-glob through glob-stream.
|
||||
* Emits files matching provided glob or array of globs. Returns a stream of Vinyl files that can be piped to plugins.
|
||||
* @param globs Glob or array of globs to read.
|
||||
* @param options Options to pass to node-glob through glob-stream.
|
||||
*/
|
||||
src: SrcMethod;
|
||||
|
||||
/**
|
||||
* Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
|
||||
* Folders that don't exist will be created.
|
||||
*
|
||||
* @param outFolder The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance.
|
||||
* @param opt
|
||||
* @param path The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance.
|
||||
* @param options
|
||||
*/
|
||||
dest: DestMethod;
|
||||
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param opt options, that are passed to the gaze library.
|
||||
* @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task().
|
||||
* Functions exactly like gulp.dest, but will create symlinks instead of copying a directory.
|
||||
* @param folder A folder path or a function that receives in a file and returns a folder path.
|
||||
* @param options
|
||||
*/
|
||||
symlink: typeof vfs.symlink;
|
||||
|
||||
/**
|
||||
* Takes a path string, an array of path strings, a glob string or an array of glob strings as globs to watch on the filesystem.
|
||||
* Also optionally takes options to configure the watcher and a fn to execute when a file changes.
|
||||
* @globs A path string, an array of path strings, a glob string or an array of glob strings that indicate which files to watch for changes.
|
||||
* @opts Options that are passed to chokidar.
|
||||
* @fn Once async completion is signalled, if another run is queued, it will be executed.
|
||||
*/
|
||||
watch: WatchMethod;
|
||||
}
|
||||
|
||||
interface GulpPlugin {
|
||||
(...args: any[]): NodeJS.ReadWriteStream;
|
||||
interface WatchOptions extends chokidar.WatchOptions {
|
||||
/**
|
||||
* The delay to wait before triggering the fn.
|
||||
* Useful for waiting on many changes before doing the work on changed files, e.g. find-and-replace on many files.
|
||||
* @default 200
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
* Whether or not a file change should queue the fn execution if the fn is already running. Useful for a long running fn.
|
||||
* @default true
|
||||
*/
|
||||
queue?: boolean;
|
||||
}
|
||||
|
||||
interface WatchMethod {
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task().
|
||||
*/
|
||||
(glob: string|string[], fn: (WatchCallback|string)): NodeJS.EventEmitter;
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task().
|
||||
*/
|
||||
(glob: string|string[], fn: (WatchCallback|string)[]): NodeJS.EventEmitter;
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param opt options, that are passed to the gaze library.
|
||||
* @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task().
|
||||
*/
|
||||
(glob: string|string[], opt: WatchOptions, fn: (WatchCallback|string)): NodeJS.EventEmitter;
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param opt options, that are passed to the gaze library.
|
||||
* @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task().
|
||||
*/
|
||||
(glob: string|string[], opt: WatchOptions, fn: (WatchCallback|string)[]): NodeJS.EventEmitter;
|
||||
|
||||
(globs: Globs, fn?: Undertaker.TaskFunction): fs.FSWatcher;
|
||||
(globs: Globs, opts?: WatchOptions, fn?: Undertaker.TaskFunction): fs.FSWatcher;
|
||||
}
|
||||
|
||||
interface DestMethod {
|
||||
/**
|
||||
* Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
|
||||
* Folders that don't exist will be created.
|
||||
*
|
||||
* @param outFolder The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance.
|
||||
* @param opt
|
||||
*/
|
||||
(outFolder: string|((file: VinylFile) => string), opt?: DestOptions): NodeJS.ReadWriteStream;
|
||||
}
|
||||
type SrcMethod = typeof vfs.src;
|
||||
|
||||
interface SrcMethod {
|
||||
/**
|
||||
* Emits files matching provided glob or an array of globs. Returns a stream of Vinyl files that can be piped to plugins.
|
||||
* @param glob Glob or array of globs to read.
|
||||
* @param opt Options to pass to node-glob through glob-stream.
|
||||
*/
|
||||
(glob: string|string[], opt?: SrcOptions): NodeJS.ReadWriteStream;
|
||||
}
|
||||
interface SeriesMethod {
|
||||
/**
|
||||
* Takes a number of task names or functions and returns a function of the composed tasks or functions.
|
||||
* When using task names, the task should already be registered.
|
||||
* When the returned function is executed, the tasks or functions will be executed in series,
|
||||
* each waiting for the prior to finish. If an error occurs, execution will stop.
|
||||
* @param tasks, string, function or array of both.
|
||||
*/
|
||||
(...tasks: string[]): NodeJS.EventEmitter;
|
||||
|
||||
(...tasks: Function[]): NodeJS.EventEmitter;
|
||||
|
||||
(task: string|string[], ...fn: Function[]): NodeJS.EventEmitter;
|
||||
|
||||
//TODO: TypeScript cannot express varargs followed by callback as a last argument...
|
||||
(task1: Strings, task2: Strings, cb?: (error?: any) => any): Function;
|
||||
(task1: Strings, task2: Strings, task3: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
(task1: Strings, task2: Strings, task3: Strings, task4: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
(task1: Strings, task2: Strings, task3: Strings, task4: Strings, task5: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
(task1: Strings, task2: Strings, task3: Strings, task4: Strings, task5: Strings, task6: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
|
||||
}
|
||||
|
||||
interface ParallelMethod {
|
||||
/**
|
||||
* Takes a number of task names or functions and returns a function of the composed tasks or functions.
|
||||
* When using task names, the task should already be registered.
|
||||
* When the returned function is executed, the tasks or functions will be executed in parallel,
|
||||
* all being executed at the same time. If an error occurs, all execution will complete.
|
||||
* @param tasks, string, function or array of both.
|
||||
*/
|
||||
(...tasks: string[]): NodeJS.EventEmitter;
|
||||
|
||||
(...tasks: Function[]): NodeJS.EventEmitter;
|
||||
|
||||
(task: string|string[], ...fn: Function[]): NodeJS.EventEmitter;
|
||||
|
||||
//TODO: TypeScript cannot express varargs followed by callback as a last argument...
|
||||
(task1: Strings, task2: Strings, cb?: (error?: any) => any): Function;
|
||||
(task1: Strings, task2: Strings, task3: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
(task1: Strings, task2: Strings, task3: Strings, task4: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
(task1: Strings, task2: Strings, task3: Strings, task4: Strings, task5: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
(task1: Strings, task2: Strings, task3: Strings, task4: Strings, task5: Strings, task6: Strings, cb?: (error?: any) => any): NodeJS.EventEmitter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to pass to node-glob through glob-stream.
|
||||
* Specifies two options in addition to those used by node-glob:
|
||||
* https://github.com/isaacs/node-glob#options
|
||||
*/
|
||||
interface SrcOptions {
|
||||
/**
|
||||
* Setting this to <code>false</code> will return <code>file.contents</code> as <code>null</code>
|
||||
* and not read the file at all.
|
||||
* Default: <code>true</code>.
|
||||
*/
|
||||
read?: boolean;
|
||||
|
||||
/**
|
||||
* Setting this to false will return <code>file.contents</code> as a stream and not buffer files.
|
||||
* This is useful when working with large files.
|
||||
* Note: Plugins might not implement support for streams.
|
||||
* Default: <code>true</code>.
|
||||
*/
|
||||
buffer?: boolean;
|
||||
|
||||
/**
|
||||
* The base path of a glob.
|
||||
*
|
||||
* Default is everything before a glob starts.
|
||||
*/
|
||||
base?: string;
|
||||
|
||||
/**
|
||||
* The current working directory in which to search.
|
||||
* Defaults to process.cwd().
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* The place where patterns starting with / will be mounted onto.
|
||||
* Defaults to path.resolve(options.cwd, "/") (/ on Unix systems, and C:\ or some such on Windows.)
|
||||
*/
|
||||
root?: string;
|
||||
|
||||
/**
|
||||
* Include .dot files in normal matches and globstar matches.
|
||||
* Note that an explicit dot in a portion of the pattern will always match dot files.
|
||||
*/
|
||||
dot?: boolean;
|
||||
|
||||
/**
|
||||
* Set to match only fles, not directories. Set this flag to prevent copying empty directories
|
||||
*/
|
||||
nodir?: boolean;
|
||||
|
||||
/**
|
||||
* By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid
|
||||
* filesystem path is returned. Set this flag to disable that behavior.
|
||||
*/
|
||||
nomount?: boolean;
|
||||
|
||||
/**
|
||||
* Add a / character to directory matches. Note that this requires additional stat calls.
|
||||
*/
|
||||
mark?: boolean;
|
||||
|
||||
/**
|
||||
* Don't sort the results.
|
||||
*/
|
||||
nosort?: boolean;
|
||||
|
||||
/**
|
||||
* Set to true to stat all results. This reduces performance somewhat, and is completely unnecessary, unless
|
||||
* readdir is presumed to be an untrustworthy indicator of file existence. It will cause ELOOP to be triggered one
|
||||
* level sooner in the case of cyclical symbolic links.
|
||||
*/
|
||||
stat?: boolean;
|
||||
|
||||
/**
|
||||
* When an unusual error is encountered when attempting to read a directory, a warning will be printed to stderr.
|
||||
* Set the silent option to true to suppress these warnings.
|
||||
*/
|
||||
silent?: boolean;
|
||||
|
||||
/**
|
||||
* When an unusual error is encountered when attempting to read a directory, the process will just continue on in
|
||||
* search of other matches. Set the strict option to raise an error in these cases.
|
||||
*/
|
||||
strict?: boolean;
|
||||
|
||||
/**
|
||||
* See cache property above. Pass in a previously generated cache object to save some fs calls.
|
||||
*/
|
||||
cache?: boolean;
|
||||
|
||||
/**
|
||||
* A cache of results of filesystem information, to prevent unnecessary stat calls.
|
||||
* While it should not normally be necessary to set this, you may pass the statCache from one glob() call to the
|
||||
* options object of another, if you know that the filesystem will not change between calls.
|
||||
*/
|
||||
statCache?: boolean;
|
||||
|
||||
/**
|
||||
* Perform a synchronous glob search.
|
||||
*/
|
||||
sync?: boolean;
|
||||
|
||||
/**
|
||||
* In some cases, brace-expanded patterns can result in the same file showing up multiple times in the result set.
|
||||
* By default, this implementation prevents duplicates in the result set. Set this flag to disable that behavior.
|
||||
*/
|
||||
nounique?: boolean;
|
||||
|
||||
/**
|
||||
* Set to never return an empty set, instead returning a set containing the pattern itself.
|
||||
* This is the default in glob(3).
|
||||
*/
|
||||
nonull?: boolean;
|
||||
|
||||
/**
|
||||
* Perform a case-insensitive match. Note that case-insensitive filesystems will sometimes result in glob returning
|
||||
* results that are case-insensitively matched anyway, since readdir and stat will not raise an error.
|
||||
*/
|
||||
nocase?: boolean;
|
||||
|
||||
/**
|
||||
* Set to enable debug logging in minimatch and glob.
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* Set to enable debug logging in glob, but not minimatch.
|
||||
*/
|
||||
globDebug?: boolean;
|
||||
}
|
||||
|
||||
interface DestOptions {
|
||||
/**
|
||||
* The output folder. Only has an effect if provided output folder is relative.
|
||||
* Default: process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Octal permission string specifying mode for any folders that need to be created for output folder.
|
||||
* Default: 0777.
|
||||
*/
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options that are passed to <code>gaze</code>.
|
||||
* https://github.com/shama/gaze
|
||||
*/
|
||||
interface WatchOptions {
|
||||
/** Interval to pass to fs.watchFile. */
|
||||
interval?: number;
|
||||
/** Delay for events called in succession for the same file/event. */
|
||||
debounceDelay?: number;
|
||||
/** Force the watch mode. Either 'auto' (default), 'watch' (force native events), or 'poll' (force stat polling). */
|
||||
mode?: string;
|
||||
/** The current working directory to base file patterns from. Default is process.cwd().. */
|
||||
cwd?: string;
|
||||
}
|
||||
|
||||
interface WatchEvent {
|
||||
/** The type of change that occurred, either added, changed or deleted. */
|
||||
type: string;
|
||||
/** The path to the file that triggered the event. */
|
||||
path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to be called on each watched file change.
|
||||
*/
|
||||
interface WatchCallback {
|
||||
(event: WatchEvent): void;
|
||||
}
|
||||
|
||||
interface TaskCallback {
|
||||
/**
|
||||
* Defines a task.
|
||||
* Tasks may be made asynchronous if they are passing a callback or return a promise or a stream.
|
||||
* @param cb callback used to signal asynchronous completion. Caller includes <code>err</code> in case of error.
|
||||
*/
|
||||
(cb?: (err?: any) => void): any;
|
||||
}
|
||||
type DestMethod = typeof vfs.dest;
|
||||
}
|
||||
|
||||
declare var gulp: gulp.Gulp;
|
||||
|
||||
export = gulp;
|
||||
declare const GulpClient: GulpClient.Gulp;
|
||||
export = GulpClient;
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
import * as gulp from 'gulp';
|
||||
import * as undertaker from 'undertaker';
|
||||
import * as registry from 'undertaker-registry';
|
||||
import * as del from "del";
|
||||
|
||||
const minify: () => any = () => { };
|
||||
const jade: () => any = () => { };
|
||||
const someplugin: () => any = () => { };
|
||||
const promisedDel: (list: string[]) => any = (list) => { };
|
||||
|
||||
gulp.src('client/templates/*.jade')
|
||||
.pipe(jade())
|
||||
.pipe(minify())
|
||||
.pipe(gulp.dest('build/minified_templates'));
|
||||
|
||||
// exclude every JS file that starts with a b except bad.js
|
||||
gulp.src(['*.js', '!b*.js', 'bad.js']);
|
||||
|
||||
// Matches 'client/js/somedir/somefile.js' and resolves `base` to `client/js/`
|
||||
gulp.src('client/js/**/*.js')
|
||||
.pipe(minify())
|
||||
.pipe(gulp.dest('build')); // Writes 'build/somedir/somefile.js'
|
||||
|
||||
gulp.src('client/js/**/*.js', { base: 'client' })
|
||||
.pipe(minify())
|
||||
.pipe(gulp.dest('build')); // Writes 'build/js/somedir/somefile.js'
|
||||
|
||||
// Emits an error if app/scripts.js doesn't exist
|
||||
gulp.src('app/scripts.js');
|
||||
|
||||
// Won't emit an error
|
||||
gulp.src('app/scripts.js', { allowEmpty: true });
|
||||
|
||||
gulp.src('./client/templates/*.jade')
|
||||
.pipe(jade())
|
||||
.pipe(gulp.dest('./build/templates'))
|
||||
.pipe(minify())
|
||||
.pipe(gulp.dest('./build/minified_templates'));
|
||||
|
||||
gulp.task(() => {
|
||||
// Do stuff
|
||||
});
|
||||
|
||||
// someTask will be the registered task function
|
||||
const someTask = gulp.task('someTask');
|
||||
|
||||
const someNextTask = () => {
|
||||
return gulp.src(['some/glob/**/*.ext']).pipe(someplugin());
|
||||
};
|
||||
|
||||
gulp.task(someTask);
|
||||
|
||||
let foo: gulp.TaskFunction = () => { };
|
||||
foo.name === 'foo'; // true
|
||||
|
||||
const bar: gulp.TaskFunction = () => { };
|
||||
bar.name === ''; // true
|
||||
|
||||
bar.name = 'bar';
|
||||
bar.name === ''; // true
|
||||
|
||||
let test: gulp.TaskFunction = (done) => {
|
||||
done();
|
||||
};
|
||||
|
||||
gulp.task(test);
|
||||
|
||||
gulp.task('clean', (done) => {
|
||||
del(['.build/'], done);
|
||||
});
|
||||
|
||||
gulp.task('somename', () => {
|
||||
return gulp.src('client/**/*.js')
|
||||
.pipe(minify())
|
||||
.pipe(gulp.dest('build'));
|
||||
});
|
||||
|
||||
gulp.task('clean', () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
del(['.build/'], (err: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('clean', () => {
|
||||
return promisedDel(['.build/']);
|
||||
});
|
||||
|
||||
gulp.task('one', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('two', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('default', gulp.parallel('one', 'two', (done) => {
|
||||
// do more stuff
|
||||
done();
|
||||
}));
|
||||
|
||||
gulp.task('one', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('two', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('default', gulp.series('one', 'two', (done) => {
|
||||
// do more stuff
|
||||
done();
|
||||
}));
|
||||
|
||||
gulp.watch('js/**/*.js', gulp.parallel('concat', 'uglify'));
|
||||
|
||||
const watcher = gulp.watch('js/**/*.js', gulp.parallel('concat', 'uglify'));
|
||||
// watcher.close
|
||||
watcher.on('change', (path, stats) => {
|
||||
console.log('File ' + path + ' was changed');
|
||||
});
|
||||
|
||||
watcher.on('unlink', (path: string) => {
|
||||
console.log('File ' + path + ' was removed');
|
||||
});
|
||||
|
||||
gulp.task('one', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('two', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('three', (done) => {
|
||||
// do stuff
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('four', gulp.series('one', 'two'));
|
||||
|
||||
gulp.task('five',
|
||||
gulp.series('four',
|
||||
gulp.parallel('three', (done) => {
|
||||
// do more stuff
|
||||
done();
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
gulp.tree();
|
||||
|
||||
gulp.tree({ deep: true });
|
||||
|
||||
// gulpfile.js
|
||||
|
||||
const companyTasks = {} as registry;
|
||||
|
||||
gulp.registry(companyTasks);
|
||||
|
||||
gulp.task('one', gulp.parallel('someCompanyTask', (done) => {
|
||||
console.log('in task one');
|
||||
done();
|
||||
}));
|
||||
|
||||
gulp.symlink("path/to/dir");
|
||||
|
||||
gulp.symlink(() => {
|
||||
return "resolved/path/to/dir";
|
||||
});
|
||||
+10
-11
@@ -2,24 +2,23 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"q": [ "q/v0" ]
|
||||
},
|
||||
"jsx": "react",
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gulp-tests.ts"
|
||||
"test/index.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
|
||||
|
||||
import gulp = require('gulp');
|
||||
import karma = require('karma');
|
||||
|
||||
@@ -13,7 +10,7 @@ function runKarma(singleRun: boolean): void {
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('test:unit:karma', ['build:test:unit'], () => runKarma(true));
|
||||
gulp.task('test:unit:karma', gulp.parallel('build:test:unit', () => runKarma(true)));
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ declare namespace Undertaker {
|
||||
}
|
||||
|
||||
interface TaskFunction extends TaskFunctionParams {
|
||||
(done?: (error?: any) => void): void | Duplex | NodeJS.Process | Promise<never> | any;
|
||||
(done: (error?: any) => void): void | Duplex | NodeJS.Process | Promise<never> | any;
|
||||
}
|
||||
|
||||
type Task = string | TaskFunction;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Reference in New Issue
Block a user