Showing posts with label git pull using nodejs. Show all posts
Showing posts with label git pull using nodejs. Show all posts

Saturday 14 December 2019

GIT Pull Using Nodejs

GIT Pull Using Nodejs

I am sharing my code to take GIT pull through NodeJS. May be this small code can help someone.

// create config module
var config = {};
to_dir_client = "path to folder...";
client_git_repo = "Bitbucket URL... ";

// export config object as a node module
export default config;

/*-----------------------------------------------------------
--- install git repo js file
-----------------------------------------------------------*/
// include modules
import config, { to_dir_client, client_git_repo } from './config';
import gitP from 'simple-git/promise';

// install repo
const git_client = gitP(to_dir_client);
git_client.checkIsRepo()
   .then(isRepo => !isRepo && initialiseClientRepo(git_client))
   .then(() => git_client.pull('origin', 'master'));

// function to add origin
function initialiseClientRepo (git) {
   return git.init()
      .then(() => git.addRemote('origin', client_git_repo))
}

Create .ICS file using PHP code

Recently worked on creating a .ics file in PHP after a very long time, code so thought to share with everybody. Please find below the comple...