Merge pull request #10798 from DanielRosenwasser/gulp-file-include

Added declarations and tests for 'gulp-file-include'.
This commit is contained in:
Andy
2016-09-24 08:08:21 -07:00
committed by GitHub
3 changed files with 101 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import gulp = require("gulp");
import fileinclude = require("gulp-file-include");
function testA() {
fileinclude({
prefix: "@@",
basepath: "/home/"
})
}
function testB() {
gulp.task("fileinclude", function () {
gulp.src(["index.html"])
.pipe(fileinclude({
prefix: "@@",
basepath: "@file"
}))
.pipe(gulp.dest("./"));
});
}
function testC() {
gulp.task("fileinclude", function () {
gulp.src(["index.html"])
.pipe(fileinclude({
filters: {
markdown: (x) => "nope"
}
}))
.pipe(gulp.dest("./"));
});
}
function testD() {
fileinclude({
context: {
arr: ["test1", "test2"]
}
});
}
function testE() {
fileinclude('@@');
}

38
gulp-file-include/index.d.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
// Type definitions for gulp-file-include 0.14.0
// Project: https://github.com/coderhaoxin/gulp-file-include
// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare function fileinclude(prefix: string): NodeJS.ReadWriteStream;
declare function fileinclude(opts: fileinclude.Options): NodeJS.ReadWriteStream;
declare namespace fileinclude {
export interface Options {
/** default: "@@" */
prefix?: string;
/** default: "" */
suffix?: string;
/**
* Can be "@file" or "@root" or some base path.
* default: "@file"
*/
basepath?: "@file" | "@root" | string;
/**
* Filters basically look like functions that get passed into '@@include'.
* When one of these functions is called, something of that name is looked
* up in this object and called to get the contents of that include.
*/
filters?: { [filter: string]: (arg: any) => string };
/**
* Effectively a context for variables used in 'if' statements.
*/
context?: { [contextVarName: string]: any };
/**
* default: false
*/
indent?: boolean;
}
}
export = fileinclude;

View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gulp-file-include-tests.ts"
]
}