Created
July 6, 2020 16:45
-
-
Save adityadeshpande/20139e9dd0b22031df15afbc23d8d81a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const debug = ""; //Import your Logger here or use Console just in case. | |
const nodegit = require("nodegit"); | |
const fs = require('fs'); | |
const path = require("path"); | |
const fse = require("fs-extra"); | |
const dir = `./backup/` | |
const repoFolder = `${dir}.git`; | |
var privateKey, publicKey, passphrase, twoWaySync, url, credentialsCallback, signature_name, signature_email; | |
module.exports = async (options) => { | |
///Initialize Git config. | |
InitGit(options); | |
///Clone Repo if not exist already. | |
try { | |
if (!fs.existsSync(repoFolder)) { | |
debug.info(`Cloning Repo.`) | |
await CloneRepo(); | |
} | |
} catch (error) { | |
debug.error("Error during Cloning Repo."); | |
debug.error(error); | |
} | |
//Prepare files for commit, maybe cleanup or renaming or conditioning. | |
PrepareFilesForCommit(); | |
/// Sync Once all files and folders are prepared. | |
try { | |
if (fs.existsSync(`${dir}.git`)) { | |
debug.info(`Attempting to push to server.`) | |
await InitSync(); | |
} | |
} catch (error) { | |
debug.error("Error during pushing to server."); | |
debug.error(error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment