Skip to content

Instantly share code, notes, and snippets.

@adityadeshpande
Created July 6, 2020 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adityadeshpande/20139e9dd0b22031df15afbc23d8d81a to your computer and use it in GitHub Desktop.
Save adityadeshpande/20139e9dd0b22031df15afbc23d8d81a to your computer and use it in GitHub Desktop.
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