From dd0b96ca5defc0a14f37d7f19973afe043704ae6 Mon Sep 17 00:00:00 2001 From: Andrey Taranov Date: Fri, 18 Dec 2015 13:00:09 +0100 Subject: [PATCH] Allow gulp build to work on Windows The problem with gulp pipeline is that it replaces /src/ with /lib/ in filenames as a regex replace operation. The regex only worked for Unix before. Here we add a 2nd regex accomodate Windows backslashes and choose between the two by looking if we're using path.win32. The Unix regex is changed to only match the package/*/src. This seemingly has no effect on the build. Fixes T6855 --- Gulpfile.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Gulpfile.js b/Gulpfile.js index eb3c3542ac..73643c962e 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -11,6 +11,16 @@ var path = require("path"); var scripts = "./packages/*/src/**/*.js"; var dest = "packages"; +var srcEx, libFragment; + +if (path.win32 === path) { + srcEx = /(packages\\[^\\]+)\\src\\/; + libFragment = "$1\\lib\\"; +} else { + srcEx = new RegExp("(packages/[^/]+)/src/"); + libFragment = "$1/lib/"; +} + gulp.task("default", ["build"]); gulp.task("build", function () { @@ -22,7 +32,7 @@ gulp.task("build", function () { })) .pipe(through.obj(function (file, enc, callback) { file._path = file.path; - file.path = file.path.replace(/^([^\\]+)\/src/, "$1/lib"); + file.path = file.path.replace(srcEx, libFragment); callback(null, file); })) .pipe(newer(dest))