-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.js
39 lines (30 loc) · 918 Bytes
/
update.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
const { simpleGit, CleanOptions } = require('simple-git');
const TEMPLATE_REPO = 'https://github.com/HelpDev/NGO-HelpDev-Storyblok.git';
(async () => {
const git = simpleGit();
// Add origin if is not added
try {
await git.init().addRemote('template', TEMPLATE_REPO);
} catch (error) {
if (!error.message.includes('already exists')) {
throw error;
}
}
// Fetch all remote
await git.raw('fetch', 'origin');
await git.raw('fetch', 'template');
// Move to template and update again
try {
await git.raw('switch', '-c', 'template', 'template/main');
} catch (error) {
if (!error.message.includes('already exists')) {
throw error;
}
await git.raw('switch', 'template');
}
await git.raw('pull');
// Move to origin main
await git.raw('switch', 'main');
// Merge to main
await git.raw('merge', 'template', '--allow-unrelated-histories');
})();