From 964d8d647001b5277f5a0309fdade125e224f829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Thu, 20 Aug 2015 11:40:54 +0200 Subject: [PATCH 1/2] [gulp-changed] Add type definitions --- gulp-changed/gulp-changed-tests.ts | 19 ++++++++++ gulp-changed/gulp-changed.d.ts | 60 ++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 gulp-changed/gulp-changed-tests.ts create mode 100644 gulp-changed/gulp-changed.d.ts diff --git a/gulp-changed/gulp-changed-tests.ts b/gulp-changed/gulp-changed-tests.ts new file mode 100644 index 000000000..ae6104eed --- /dev/null +++ b/gulp-changed/gulp-changed-tests.ts @@ -0,0 +1,19 @@ +/// +/// +/// + +import * as gulp from "gulp"; +import changed = require("gulp-changed"); +import minifyHtml = require("gulp-minify-html"); + +// Without options +gulp.src("*.html") + .pipe(changed("build")) + .pipe(minifyHtml()) + .pipe(gulp.dest("build")); + +// Without some options +gulp.src("*.html") + .pipe(changed("build", { hasChanged: changed.compareSha1Digest })) + .pipe(minifyHtml()) + .pipe(gulp.dest("build")); diff --git a/gulp-changed/gulp-changed.d.ts b/gulp-changed/gulp-changed.d.ts new file mode 100644 index 000000000..f2a3e0d64 --- /dev/null +++ b/gulp-changed/gulp-changed.d.ts @@ -0,0 +1,60 @@ +// Type definitions for gulp-changed +// Project: https://github.com/sindresorhus/gulp-changed +// Definitions by: Thomas Corbière +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-changed" +{ + import { Transform } from "stream"; + import File = require("vinyl"); + + interface IComparator + { + /** + * @param stream Should be used to queue sourceFile if it passes some comparison + * @param callback Should be called when done + * @param sourceFile File to operate on + * @param destPath Destination for sourceFile as an absolute path + */ + (stream: Transform, callback: Function, sourceFile: File, destPath: string): void; + } + + interface IDestination + { + (file: string|Buffer): string; + } + + interface IOptions + { + /** + * The working directory the folder is relative to. + * @default process.cwd() + */ + cwd?: string; + + /** + * Extension of the destination files. + */ + extension?: string; + + /** + * Function that determines whether the source file is different from the destination file. + * @default changed.compareLastModifiedTime + */ + hasChanged?: IComparator; + } + + interface IGulpChanged + { + (destination: string|IDestination, options?: IOptions): NodeJS.ReadWriteStream; + + compareLastModifiedTime: IComparator; + compareSha1Digest: IComparator; + } + + const changed: IGulpChanged; + export = changed; +} From 829c564bf1e86a14d35ebaebe78384c281e632d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Thu, 20 Aug 2015 12:37:27 +0200 Subject: [PATCH 2/2] [gulp-changed] Fix typo --- gulp-changed/gulp-changed-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulp-changed/gulp-changed-tests.ts b/gulp-changed/gulp-changed-tests.ts index ae6104eed..dae92e0fd 100644 --- a/gulp-changed/gulp-changed-tests.ts +++ b/gulp-changed/gulp-changed-tests.ts @@ -12,7 +12,7 @@ gulp.src("*.html") .pipe(minifyHtml()) .pipe(gulp.dest("build")); -// Without some options +// With some options gulp.src("*.html") .pipe(changed("build", { hasChanged: changed.compareSha1Digest })) .pipe(minifyHtml())