-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
p5Update.js
85 lines (80 loc) · 2.23 KB
/
p5Update.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* @todo: Create a documentation for the usage
*/
const replace = require("replace-in-file");
//Specify the release you want to update to
const release = "0.8.0";
const paths = ["./**/index.html"];
const ignored_files = ["./_site/**/*.html"];
const p5_js = {
name: "p5.js",
files: paths,
from: new RegExp(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/[0-9].[0-9].[0-9]/p5.js"
),
to: `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${release}/p5.min.js`,
ignore: ignored_files
};
const p5_sound_js = {
name: "p5.sound.js",
files: paths,
from: new RegExp(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/[0-9].[0-9].[0-9]/addons/p5.sound.js"
),
to: `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${release}/addons/p5.sound.min.js`,
ignore: ignored_files
};
const p5_dom_js = {
name: "p5.dom.js",
files: paths,
from: new RegExp(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/[0-9].[0-9].[0-9]/addons/p5.dom.js"
),
to: `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${release}/addons/p5.dom.min.js`,
ignore: ignored_files
};
const p5_min_js = {
name: "p5.min.js",
files: paths,
from: new RegExp(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/[0-9].[0-9].[0-9]/p5.min.js"
),
to: `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${release}/p5.min.js`,
ignore: ignored_files
};
const p5_sound_min_js = {
name: "p5.sound.min.js",
files: paths,
from: new RegExp(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/[0-9].[0-9].[0-9]/addons/p5.sound.min.js"
),
to: `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${release}/addons/p5.sound.min.js`,
ignore: ignored_files
};
const p5_dom_min_js = {
name: "p5.dom.min.js",
files: paths,
from: new RegExp(
"https://cdnjs.cloudflare.com/ajax/libs/p5.js/[0-9].[0-9].[0-9]/addons/p5.dom.min.js"
),
to: `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${release}/addons/p5.dom.min.js`,
ignore: ignored_files
};
const options = [
p5_js,
p5_sound_js,
p5_dom_js,
p5_min_js,
p5_sound_min_js,
p5_dom_min_js
];
(async () => {
for (const option of options) {
try {
const changes = await replace(option);
console.log(`${option.name}: `, changes.join(", "));
} catch (error) {
console.error("Error occurred:", error);
}
}
})();