-
Notifications
You must be signed in to change notification settings - Fork 298
/
auto-bump-version.js
37 lines (31 loc) · 1.02 KB
/
auto-bump-version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Auto replace old version numbers
// this script searches and replaces the old version numbers in the library
// and changes them to reflect latest tagged version of the library for release
// created by oran collins
// github.com/wisehackermonkey
// 20200701
// the version of the package is found in the file
// package.json
// {
// "name": "p5.collide2d",
// "version": "0.7.1", <-here
// ...
// }
let package_json = require("./package.json");
let version = package_json.version;
console.log(`Updating Package to version: ` + version)
const replace = require("replace-in-file");
// replace all instances of pattern "vX.X.X" within the file p5.collide2d.js
// EX: v0.7.1 -> v0.8.1
try {
const results = replace.sync({
files: "p5.collide2d.js",
// example of what regex does regexr.com/57k30
from: /(v)(\d+)\.(\d+)\.(\d+)/g,
to: "v" + version,
});
console.log("Replacement results:", results);
} catch (error) {
console.error("Error occurred:", error);
}