ホーム

Automatically push regularly to GitHub

AutomaticPush.js

This is a project that pushes regularly to GitHub and grows "weed". creating a daemon using "forever" of Node.js. Also using "fs" for create and delete files cuz I need enables regular push to GitHub.

Implementation

var flag = "on";

setInterval(() => { 

function writeFile(path, data) {
  fs.writeFile(path, data, function (err) {
    if (err) {
        throw err;
    }
  });
}

writeFile(`${flag}.txt`, "");

const exec = require('child_process').exec;
exec('git add . -A', (err, stdout, stderr) => {
  if (err) { console.log(err); }
  console.log(stdout);
});

exec('git commit -m "commit"', (err, stdout, stderr) => {
  if (err) { console.log(err); }
  console.log(stdout);
});

exec('git push origin master', (err, stdout, stderr) => {
  if (err) { console.log(err); }
  console.log(stdout);
});


    if (flag === "on"){
        flag = "off";
        fs.unlink('on.txt', function (err) {});

    }else if (flag === "off"){
       flag = "on";
       fs.unlink('off.txt', function (err) {});
    }

 }, 5000);
Pocket
LinkedIn にシェア

-ホーム

Copyright© off , 2020 All Rights Reserved Powered by AFFINGER5.