mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add definitions and tests for gulp-inject
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/// <reference path="./gulp-inject.d.ts" />
|
||||
/// <reference path="../gulp/gulp.d.ts" />
|
||||
|
||||
import gulp = require("gulp");
|
||||
import inject = require("gulp-inject");
|
||||
|
||||
gulp.task("inject:simple", () => {
|
||||
gulp.src("src/index.html")
|
||||
.pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false })))
|
||||
.pipe(gulp.dest("build"));
|
||||
});
|
||||
|
||||
gulp.task("inject:relative", () => {
|
||||
gulp.src(["src/index.html"])
|
||||
.pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { relative: true }))
|
||||
.pipe(gulp.dest("build"));
|
||||
});
|
||||
|
||||
gulp.task("inject:starttag", () => {
|
||||
gulp.src(["src/index.html"])
|
||||
.pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { starttag: "<!-- inject:head:{{ext}} -->" }))
|
||||
.pipe(gulp.dest("build"));
|
||||
});
|
||||
|
||||
gulp.task("inject:name", () => {
|
||||
gulp.src(["src/index.html"])
|
||||
.pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css"], { read: false }), { name: "head" }))
|
||||
.pipe(gulp.dest("build"));
|
||||
});
|
||||
|
||||
gulp.task("inject:transform", () => {
|
||||
gulp.src(["files.json"])
|
||||
.pipe(inject(gulp.src(["src/**/*.js", "src/**/*.css", "src/**/*.html"], { read: false }), {
|
||||
starttag: "\"{{ext}}\": [",
|
||||
endtag: "]",
|
||||
transform: (filepath, file, i, length) => {
|
||||
return " \"" + filepath + "\"" + (i + 1 < length ? "," : "");
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest("build"));
|
||||
});
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// Type definitions for gulp-inject
|
||||
// Project: https://github.com/klei/gulp-inject
|
||||
// Definitions by: Keita Kagurazaka <https://github.com/k-kagurazaka>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../vinyl/vinyl.d.ts" />
|
||||
|
||||
declare module "gulp-inject" {
|
||||
|
||||
import File = require("vinyl");
|
||||
|
||||
interface ITagFunction {
|
||||
(targetExt: string, sourceExt: string): string;
|
||||
}
|
||||
|
||||
interface ITransformFunction {
|
||||
(filepath: string, file?: File, index?: number, length?: number, targetFile?: File): string;
|
||||
}
|
||||
|
||||
interface IOptions {
|
||||
ignorePath?: string | string[];
|
||||
relative?: boolean;
|
||||
addPrefix?: string;
|
||||
addRootSlash?: boolean;
|
||||
name?: string;
|
||||
starttag?: string | ITagFunction;
|
||||
endtag?: string | ITagFunction;
|
||||
transform?: ITransformFunction;
|
||||
selfClosingTag?: boolean;
|
||||
}
|
||||
|
||||
function inject(sources: NodeJS.ReadableStream, options?: IOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
export = inject;
|
||||
}
|
||||
Reference in New Issue
Block a user