当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript gulp-insert.transform函数代码示例

本文整理汇总了TypeScript中gulp-insert.transform函数的典型用法代码示例。如果您正苦于以下问题:TypeScript transform函数的具体用法?TypeScript transform怎么用?TypeScript transform使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了transform函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getCompilerSettings

gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
    const servicesProject = tsc.createProject("src/services/tsconfig.json", getCompilerSettings({ removeComments: false }, /*useBuiltCompiler*/false));
    const {js, dts} = servicesProject.src()
        .pipe(newer(servicesFile))
        .pipe(sourcemaps.init())
        .pipe(tsc(servicesProject));
    const completedJs = js.pipe(prependCopyright())
        .pipe(sourcemaps.write("."));
    const completedDts = dts.pipe(prependCopyright(/*outputCopyright*/true))
        .pipe(insert.transform((contents, file) => {
            file.path = standaloneDefinitionsFile;
            return contents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, "$1$2enum $3 {$4");
        }));
    return merge2([
        completedJs,
        completedJs.pipe(clone())
            .pipe(insert.transform((content, file) => (file.path = nodePackageFile, content))),
        completedDts,
        completedDts.pipe(clone())
            .pipe(insert.transform((content, file) => {
                file.path = nodeDefinitionsFile;
                return content + "\r\nexport = ts;";
            }))
            .pipe(gulp.dest(builtLocalDirectory)),
        completedDts.pipe(clone())
            .pipe(insert.transform((content, file) => {
                file.path = nodeStandaloneDefinitionsFile;
                return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
            }))
    ]).pipe(gulp.dest(builtLocalDirectory));
});
开发者ID:buildyourtomorrow,项目名称:build-your-tomorrow-final,代码行数:31,代码来源:Gulpfile.ts

示例2: function

gulp.task("compile", function() {
	var tsResult = tsProject.src()
		.pipe(sourcemaps.init())
		.pipe(ts(tsProject));
	
	var dts = tsResult.dts
		.pipe(insert.transform(function(contents: string, file: any) {
			contents = contents.replace(/\/\/\/\s*\<reference path=".*"\s*\/\>\s*\n/ig, "");
			contents += "declare module \"updraft\" {\n" +
									"	export = Updraft;\n" +
									"}\n";
			return contents;
		}));
	
	dts = tsResult.dts.pipe(gulp.dest("./"));
	
	var js = tsResult.js;
	
	js = js.pipe(insert.transform(function(contents: string, file: any) {
		contents = contents.replace(/(Updraft = {})/g, "/* istanbul ignore next */ $1");
		contents = contents.replace(/(var _a(,|;))/g, "/* istanbul ignore next */ $1");
		return contents;
	}));
	

	if(minify) {
		js = js.pipe(uglify());
	}
	
	js = js
		.pipe(sourcemaps.write("./"))
		.pipe(gulp.dest("./"));

	return merge([dts, js]);
});
开发者ID:arolson101,项目名称:updraft,代码行数:35,代码来源:Gulpfile.ts

示例3:

gulp.task(typesMapJson, /*help*/ false, [], () => {
    return gulp.src("src/server/typesMap.json")
        .pipe(insert.transform((contents, file) => {
            JSON.parse(contents);
            return contents;
        }))
        .pipe(gulp.dest(builtLocalDirectory));
});
开发者ID:sinclairzx81,项目名称:TypeScript,代码行数:8,代码来源:Gulpfile.ts

示例4: baselineDelete

function baselineDelete(subfolder = "") {
    return gulp.src(["tests/baselines/local/**/*.delete"])
        .pipe(insert.transform((content, fileObj) => {
            const target = path.join(refBaseline, fileObj.relative.substr(0, fileObj.relative.length - ".delete".length));
            del.sync(target);
            del.sync(fileObj.path);
            return "";
        }));
}
开发者ID:buildyourtomorrow,项目名称:build-your-tomorrow-final,代码行数:9,代码来源:Gulpfile.ts

示例5:

gulp.task('gulp-insert-tests', () => {
    return gulp.src('*.js')
        .pipe(insert.prepend('/* Inserted using gulp-insert prepend method */\n'))
        .pipe(insert.prepend('\n/* Inserted using gulp-insert append method */'))
        .pipe(insert.wrap(
            '/* Inserted using gulp-insert wrap method */\n',
            '\n/* Inserted using gulp-insert wrap method */'
        ))
        .pipe(insert.transform((contents, file) => {
            var comment = '/* Local file: ' + file.path + ' */\n';
            return comment + contents;
        }))
        .pipe(gulp.dest('gulp-insert'));
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:14,代码来源:gulp-insert-tests.ts

示例6: getCompilerSettings

gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
    const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true));
    const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src()
        .pipe(sourcemaps.init())
        .pipe(newer(tsserverLibraryFile))
        .pipe(serverLibraryProject());

    return merge2([
        js.pipe(prependCopyright())
            .pipe(sourcemaps.write("."))
            .pipe(gulp.dest(".")),
        dts.pipe(prependCopyright(/*outputCopyright*/true))
            .pipe(insert.transform((content) => {
                return content + "\r\nexport = ts;\r\nexport as namespace ts;";
            }))
            .pipe(gulp.dest("."))
    ]);
});
开发者ID:garthk,项目名称:TypeScript,代码行数:18,代码来源:Gulpfile.ts

示例7: RegExp

gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => {
    const fileMatcher = RegExp(cmdLineOptions["files"]);
    const lintOptions = getLinterOptions();
    let failed = 0;
    return gulp.src(lintTargets)
        .pipe(insert.transform((contents, file) => {
            if (!fileMatcher.test(file.path)) return contents;
            const result = lintFile(lintOptions, file.path);
            if (result.failureCount > 0) {
                console.log(result.output);
                failed += result.failureCount;
            }
            return contents; // TODO (weswig): Automatically apply fixes? :3
        }))
        .on("end", () => {
            if (failed > 0) {
                console.error("Linter errors.");
                process.exit(1);
            }
        });
});
开发者ID:blueelvis,项目名称:TypeScript,代码行数:21,代码来源:Gulpfile.ts


注:本文中的gulp-insert.transform函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。