forked from stryker-mutator/stryker-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-integrationtest.js
23 lines (19 loc) · 1.09 KB
/
prepare-integrationtest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs');
var newVersionNumber = process.argv.slice(2);
const replaceVersionNumber = (path, oldString, newString) => {
const fileContent = fs.readFileSync(path, { encoding: 'UTF-8' });
if (!fileContent.includes(oldString)) {
throw new Error(`The file at ${path} did not contain ${oldString}!`);
}
const oldStringStart = fileContent.indexOf(oldString);
const oldStringEnd = oldStringStart + oldString.length;
const updatedFileContent = fileContent.substr(0, oldStringStart) + newString + fileContent.substr(oldStringEnd);
fs.writeFileSync(path, updatedFileContent, { encoding: 'UTF-8' });
};
const packages = [
{ csproj: './integrationtests/IntegrationTests/ExampleProject.XUnit/ExampleProject.XUnit.csproj' },
];
packages.forEach(package => {
console.log(`Updating DotNetCliToolReference version number in ${package.csproj}`);
replaceVersionNumber(package.csproj, `<DotNetCliToolReference Include="StrykerMutator.DotNetCoreCli" Version="*" />`, `<DotNetCliToolReference Include="StrykerMutator.DotNetCoreCli" Version="${newVersionNumber}" />`);
});