life-todo

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

git.js (493B)


      1 const simpleGit = require('simple-git');
      2 const path = require('path');
      3 
      4 const DATA_REPO = path.join(__dirname, '..', 'data', 'repo');
      5 const git = simpleGit(DATA_REPO);
      6 
      7 async function commitAndPush(message) {
      8   await git.add(['today.md', 'backlog.md', 'archive', 'conversations']);
      9   const status = await git.status();
     10 
     11   if (status.staged.length === 0) {
     12     return; // nothing changed, skip commit
     13   }
     14 
     15   await git.commit(message);
     16   await git.push();
     17 }
     18 
     19 module.exports = { commitAndPush };