-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.js
83 lines (59 loc) · 1.66 KB
/
git.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
/**
* Command definitions module
*
* @author Anthony Wilson
*/
"use strict";
const { exec } = require("child_process");
/**
* @async
* Pulls changes from the remote copy of the "Nomic" website repo.
* @param {Function} callback Called when the git command finishes execution
*/
exports.pull = async (callback) => {
exec("./git-scripts/site-pull.bash", (error, stdout, stderr) => {
callback({
error: error,
stdout: stdout,
stderr: stderr
});
});
}
/**
* @async
* Pushes changes in the local copy of the "Nomic" website repo to the remote repo.
* @param {string} message The commit message to use
* @param {Function} callback Called when the git command finishes execution
*/
exports.push = async (message, callback) => {
exec("./git-scripts/site-push.bash " + SecureInfo.gitToken + " " + '"'+message.replaceAll('"','\\"')+'"', (error, stdout, stderr) => {
callback({
error: error,
stdout: stdout,
stderr: stderr
});
});
}
/**
* @async
* Identify if the local repo is ahead of or behind the remote repo.
* @param {Function} callback Called when the git command finishes execution
*/
exports.sync = async (callback) => {
//Use git-diff to check whether the local repo is ahead of/behind the remote repo
//Sync accordingly
}
/**
* @async
* Returns the output of "git status".
* @param {Function} callback Called when the git command finishes execution
*/
exports.status = async (callback) => {
exec("./git-scripts/site-status.bash", (error, stdout, stderr) => {
callback({
error: error,
stdout: stdout,
stderr: stderr
});
});
}