forked from CodingTrain/website-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp5Update.js
52 lines (47 loc) · 1.49 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
/**
* @todo: Create a documentation for the usage
*/
const replace = require('replace-in-file');
//Specify the release you want to update to
const old_release = '1.1.4';
const release = '1.1.9';
const paths = ['./**/index.html'];
const ignored_files = ['./_site/**/*.html'];
const p5_js = {
name: 'p5.js',
files: paths,
from: new RegExp(`https://cdn.jsdelivr.net/npm/p5@${old_release}/lib/p5.min.js`),
to: `https://cdn.jsdelivr.net/npm/p5@${release}/lib/p5.min.js`,
ignore: ignored_files,
};
const p5_sound_js = {
name: 'p5.sound.js',
files: paths,
from: new RegExp(`https://cdn.jsdelivr.net/npm/p5@${old_release}/lib/addons/p5.sound.min.js`),
to: `https://cdn.jsdelivr.net/npm/p5@${release}/lib/addons/p5.sound.min.js`,
ignore: ignored_files,
};
const p5_min_js = {
name: 'p5.min.js',
files: paths,
from: new RegExp(`https://cdn.jsdelivr.net/npm/p5@${old_release}/lib/p5.min.js`),
to: `https://cdn.jsdelivr.net/npm/p5@${release}/lib/p5.min.js`,
ignore: ignored_files,
};
const p5_sound_min_js = {
name: 'p5.sound.min.js',
files: paths,
from: new RegExp(`https://cdn.jsdelivr.net/npm/p5@${old_release}/lib/addons/p5.sound.min.js`),
to: `https://cdn.jsdelivr.net/npm/p5@${release}/lib/addons/p5.sound.min.js`,
ignore: ignored_files,
};
const options = [p5_js, p5_sound_js, p5_min_js, p5_sound_min_js];
(async () => {
for (const option of options) {
try {
await replace(option);
} catch (error) {
console.error('Error occurred:', error);
}
}
})();