From 2a97d41aa8644e36e549cc024383fad4266c5e52 Mon Sep 17 00:00:00 2001 From: GrishmaM Date: Mon, 12 Sep 2022 13:57:55 +0530 Subject: [PATCH] Intial commit by simplegit --- mynewfile.txt | 1 + script.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 mynewfile.txt create mode 100644 script.js diff --git a/mynewfile.txt b/mynewfile.txt new file mode 100644 index 0000000..72fc46c --- /dev/null +++ b/mynewfile.txt @@ -0,0 +1 @@ +Hello content! \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..c174f00 --- /dev/null +++ b/script.js @@ -0,0 +1,50 @@ + +var fs = require('fs'); +const simpleGit = require('simple-git'); +const git = simpleGit(); +const shellJs = require('shelljs'); +// console.log(shellJs.ls()); + +async function test() { + // shellJs.cd('~/Documents/projects/githubAuto'); +const repo = 'githubAuto'; +const userName = 'GrishmaM'; +const password = '3Mgrishma'; +const token = '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' +// Set up GitHub url like this so no manual entry of user pass needed +const gitHubUrl = `https://${userName}:${token}@github.com/${userName}/${repo}`; +// add local git config like username and email +git.addConfig('user.email','grishma.voilet@gmail.com'); +git.addConfig('user.name','GrishmaM'); + + + +try { +// await git +// .clone(gitHubUrl) +// .then(() => console.log('finished')) +// .catch((err) => console.error('failed: ', err)); +// // shellJs.cd('./githubAuto'); +// process.chdir('./githubAuto'); +// console.log(shellJs.ls()); + // await git.init(); + await git.checkoutLocalBranch('newBranch1') + +// await git.addRemote('origin', gitHubUrl);\ + fs.appendFile('mynewfile.txt', 'Hello content!', function (err) { + if (err) throw err; + console.log('Saved!'); + }); + await git.add('.') + console.log('adding files done'); + await git.commit('Intial commit by simplegit') + console.log('commmit done'); + await git.push('origin','newBranch1') + console.log('repo successfully pushed'); +} catch (e) { + /* handle all errors here */ + console.log(e) +} +} + +test()