added publish (git add, git push)
This commit is contained in:
48
js/model.js
48
js/model.js
@@ -57,8 +57,6 @@ class Model {
|
||||
}
|
||||
|
||||
async dirGitStatus(list) {
|
||||
let dirlist = [list[0]];
|
||||
|
||||
for (let i = 1; i < list.length; i++) {
|
||||
if (Array.isArray(list[i])) {
|
||||
await this.dirGitStatus(list[i]);
|
||||
@@ -103,6 +101,52 @@ class Model {
|
||||
});
|
||||
}
|
||||
|
||||
async gitAddAll(dirTree) {
|
||||
if (!dirTree) {
|
||||
dirTree = await this.getDirTree();
|
||||
}
|
||||
for (let i = 1; i < dirTree.length; i++) {
|
||||
if (Array.isArray(dirTree[i])) {
|
||||
await this.gitAddAll(dirTree[i]);
|
||||
} else {
|
||||
await git.add({
|
||||
fs,
|
||||
dir,
|
||||
filepath: dirTree[0].substring(1) + dirTree[i],
|
||||
});
|
||||
console.log(dirTree[0].substring(1) + dirTree[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async gitCommit(msg) {
|
||||
await git.commit({
|
||||
fs,
|
||||
dir,
|
||||
message: msg,
|
||||
author: {
|
||||
name: localStorage.getItem("name"),
|
||||
email: localStorage.getItem("email"),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async gitPush(gitUser, gitPass) {
|
||||
let pushResult = await git.push({
|
||||
fs,
|
||||
http,
|
||||
dir,
|
||||
onAuth: (url) => {
|
||||
const auth = {
|
||||
username: gitUser,
|
||||
password: gitPass,
|
||||
};
|
||||
return auth;
|
||||
},
|
||||
});
|
||||
console.log(pushResult);
|
||||
}
|
||||
|
||||
setRepo(repoURL) {
|
||||
localStorage.setItem("repo", repoURL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user