forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type definitions for gulp-html-replace
- Loading branch information
1 parent
7b3d5a6
commit d70c92f
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/// <reference path="gulp-html-replace.d.ts" /> | ||
/// <reference path="../gulp/gulp.d.ts" /> | ||
/// <reference path="../node/node.d.ts" /> | ||
|
||
import * as gulp from 'gulp'; | ||
import * as htmlreplace from 'gulp-html-replace'; | ||
|
||
// Examples taken from README.md of the gulp-html-replace project: | ||
// https://www.npmjs.com/package/gulp-html-replace | ||
|
||
// Simple examples | ||
gulp.task('simple1', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ js: 'js/main.js' })) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
|
||
gulp.task('simple2', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ js: ['js/monster.js', 'js/hero.js'] })) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
|
||
// Advanced examples | ||
gulp.task('advanced1', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ | ||
js: 'js/main.js', | ||
tpl: '<img src="%s" align="left" />' | ||
})) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
|
||
gulp.task('advanced2', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ | ||
js: ['data-main.js', 'require-src.js'], | ||
tpl: '<img src="%s" align="left" />' | ||
})) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
|
||
// Extended replacements | ||
gulp.task('ext1', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ | ||
js: { | ||
src: null, | ||
tpl: '<script src="%f".js></script>' | ||
} | ||
})) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
|
||
gulp.task('ext2', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ | ||
js: { | ||
src: 'dir', | ||
tpl: '<script src="%f".js></script>' | ||
} | ||
})) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
|
||
// Options example | ||
gulp.task('options1', () => { | ||
gulp.src('src') | ||
.pipe(htmlreplace({ | ||
js: { | ||
src: null, | ||
tpl: '<script src="%f".js></script>' | ||
} | ||
}, { | ||
keepUnassigned: false, | ||
keepBlockTags: false, | ||
resolvePaths: false | ||
})) | ||
.pipe(gulp.dest('dest')); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Type definitions for gulp-html-replace v1.5.5 | ||
// Project: https://www.npmjs.com/package/gulp-html-replace | ||
// Definitions by: Peter Juras <https://github.com/peterjuras> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
/// <reference path="../node/node.d.ts" /> | ||
|
||
declare module "gulp-html-replace" { | ||
interface AdvancedTask { | ||
src: string | string[]; | ||
tpl: string; | ||
} | ||
|
||
interface Tasks { | ||
[taskId: string] : string | string[] | AdvancedTask; | ||
} | ||
|
||
interface Options { | ||
keepUnassigned?: boolean; | ||
keepBlockTags?: boolean; | ||
resolvePaths?: boolean; | ||
} | ||
|
||
interface HtmlReplace { | ||
(tasks: Tasks, options?: Options) : NodeJS.ReadWriteStream; | ||
} | ||
|
||
const htmlReplace : HtmlReplace; | ||
export = htmlReplace; | ||
} |