diff --git a/gulp-file-include/gulp-file-include-tests.ts b/gulp-file-include/gulp-file-include-tests.ts new file mode 100644 index 0000000000..624d13a3fa --- /dev/null +++ b/gulp-file-include/gulp-file-include-tests.ts @@ -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('@@'); +} \ No newline at end of file diff --git a/gulp-file-include/index.d.ts b/gulp-file-include/index.d.ts new file mode 100644 index 0000000000..9b3acb7d89 --- /dev/null +++ b/gulp-file-include/index.d.ts @@ -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 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +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; \ No newline at end of file diff --git a/gulp-file-include/tsconfig.json b/gulp-file-include/tsconfig.json new file mode 100644 index 0000000000..82b98c8f9f --- /dev/null +++ b/gulp-file-include/tsconfig.json @@ -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" + ] +} \ No newline at end of file