From 0c738e3aaa43a6f548c2ca208765431636b06545 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 21 Jan 2019 11:37:59 +0100 Subject: [PATCH] MOBILE-2836 gulp: Fix lang build in Windows --- gulpfile.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 17f687ba2..c4deb448f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -47,7 +47,13 @@ function treatFile(file, data) { return; // ignore } try { - var path = file.path.substr(file.path.lastIndexOf('/src/') + 5); + var srcPos = file.path.lastIndexOf('/src/'); + if (srcPos == -1) { + // It's probably a Windows environment. + srcPos = file.path.lastIndexOf('\\src\\'); + } + + var path = file.path.substr(srcPos + 5); data[path] = JSON.parse(file.contents.toString()); } catch (err) { console.log('Error parsing JSON: ' + err); @@ -65,7 +71,7 @@ function treatMergedData(data) { var mergedOrdered = {}; for (var filepath in data) { - var pathSplit = filepath.split('/'), + var pathSplit = filepath.split(/[\/\\]/), prefix; pathSplit.pop();