-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
28 lines (25 loc) · 1.09 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const gulp = require("gulp");
const ts = require("gulp-typescript");
const path = require("path");
const flatmap = require("gulp-flatmap");
const replace = require('gulp-replace');
const concat = require('gulp-concat');
gulp.task("build-cosmos-server-scripts", function() {
const sharedScripts = "CosmosServerScriptHelpers/*.ts";
const tsServerSideScripts = "StoredProcedures/**/*.ts";
return gulp.src(tsServerSideScripts)
.pipe(flatmap((stream, file) =>
{
let outFile = path.join(path.dirname(file.relative), path.basename(file.relative, ".ts") + ".js");
let tsProject = ts.createProject("tsconfig.json");
return stream
.pipe(gulp.src(sharedScripts))
.pipe(tsProject())
.pipe(replace(/^\s*import .+;\s*$/gm, ""))
.pipe(replace(/^\s*export .+;\s*$/gm, ""))
.pipe(replace(/^\s*export /gm, ""))
.pipe(concat(outFile))
.pipe(gulp.dest("StoredProcedures"));
}));
});
gulp.task("default", gulp.series("build-cosmos-server-scripts"));