Skip to content

Commit

Permalink
Fix version checking of GulpFiles.js
Browse files Browse the repository at this point in the history
  • Loading branch information
GuimDev committed Dec 6, 2018
1 parent 3ba2b58 commit 4524ab2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions builderGulp/Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,32 @@ function getFileContent(filename) {
return fs.readFileSync(filename).toString();
}

function indexesIn(str, pattern) {
const result = [];
for (let i = 0; i < str.length; ++i)
if (str.substring(i, i + pattern.length) == pattern)
result.push(i);

return result;
}

function getVersion() {
const txtFile = getFileContent(addonConfig.modName + ".txt");

const version = (txtFile.match(/\n\#\# Version\: (\d{1,3}\.\d{1,3}\.\d{1,3}[a-z]?)/) || [])[1];

if (!version) {
console.log("Bad version in header of " + addonConfig.modName + ".txt");
log("Bad version in header of " + addonConfig.modName + ".txt");
process.exit();
}

for (let i = 0, content, match, file; i < addonConfig.filesWithVersionNumber.length; i++) {
file = addonConfig.filesWithVersionNumber[i];
content = getFileContent(file[0]);
match = content.match(new RegExp(version, "g")) || [];
match = indexesIn(content, version) || [];
if (match.length !== file[1]) {
console.log(`Error: Version not find. ${file[0]} ${match.length}/${file[1]}`);
console.log(`Current version: ${version}`);
log(`Error: Version not find. ${file[0]} ${match.length}/${file[1]}`);
log(`Current version: ${version}`);
process.exit();
}
}
Expand Down

0 comments on commit 4524ab2

Please sign in to comment.