Skip to content

Commit c180bdd

Browse files
committed
Fixed bug with update project versions promises
1 parent 2945f19 commit c180bdd

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Developer Tools/build.js

+18-15
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,37 @@ function updateProjectVersion() {
2222
const nuget = path.resolve('./TweetinviAPI/TweetinviAPI.nuspec');
2323
const clientHandler = path.resolve('../Tweetinvi.WebLogic/TwitterClientHandler.cs');
2424

25-
projectFilePaths.forEach(filepath => {
26-
fileHelper.replace(filepath, /<VersionPrefix>([0-9\.]+[0-9])<\/VersionPrefix>/g, `<VersionPrefix>${buildInfos.version}</VersionPrefix>`).then(() => {
25+
var allUpdates = [];
26+
27+
allUpdates = projectFilePaths.map(filepath => {
28+
return fileHelper.replace(filepath, /<VersionPrefix>([0-9\.]+[0-9])<\/VersionPrefix>/g, `<VersionPrefix>${buildInfos.version}</VersionPrefix>`).then(() => {
2729
console.log(filepath + ' version has been updated!');
2830
});
29-
});
31+
}).concat(allUpdates);
3032

31-
assemblyInfosFilePaths.forEach(filepath => {
32-
fileHelper.replace(filepath, /\[assembly: (AssemblyVersion|AssemblyFileVersion)\("([0-9\.]+[0-9])"\)\]/g, `[assembly: $1("${buildInfos.version}")]`).then(() => {
33+
allUpdates = assemblyInfosFilePaths.map(filepath => {
34+
return fileHelper.replace(filepath, /\[assembly: (AssemblyVersion|AssemblyFileVersion)\("([0-9\.]+[0-9])"\)\]/g, `[assembly: $1("${buildInfos.version}")]`).then(() => {
3335
console.log(filepath + ' version has been updated!');
3436
});
35-
});
37+
}).concat(allUpdates);
3638

37-
fileHelper.replace(nuget, /<version>[0-9\.]+[0-9]<\/version>/g, `<version>${buildInfos.version}</version>`).then(() => {
39+
allUpdates.push(fileHelper.replace(nuget, /<version>[0-9\.]+[0-9]<\/version>/g, `<version>${buildInfos.version}</version>`).then(() => {
3840
return fileHelper.replace(
3941
nuget,
4042
/<releaseNotes>https:\/\/github.com\/linvi\/tweetinvi\/releases\/tag\/[0-9\.]*<\/releaseNotes>/g,
4143
`<releaseNotes>https://github.com/linvi/tweetinvi/releases/tag/${buildInfos.version}</releaseNotes>`)
4244
}).then(() => {
4345
console.log('Nuget spec has been updated.')
44-
});
46+
}));
4547

46-
fileHelper.replace(clientHandler, /"Tweetinvi\/(\d+(\.\d+)*)(.x)?"/, `"Tweetinvi/${buildInfos.version}"`).then(() => {
48+
allUpdates.push(fileHelper.replace(clientHandler, /"Tweetinvi\/(\d+(\.\d+)*)(.x)?"/, `"Tweetinvi/${buildInfos.version}"`).then(() => {
4749
console.log('User agent updated!');
50+
}));
51+
52+
return Promise.all(allUpdates).then(() => {
53+
console.log('');
54+
console.log('******************************************');
55+
console.log('');
4856
});
4957
};
5058

@@ -53,9 +61,4 @@ function buildDotNet() {
5361
}).then(() => {
5462
return shell.spawn('dotnet build');
5563
});
56-
}
57-
58-
// const filepaths = glob.sync("../**/*.csproj");
59-
// filepaths.forEach(filepath => {
60-
// console.log(filepath);
61-
// });
64+
}

0 commit comments

Comments
 (0)