]>
git.r.bdr.sh - rbdr/blog/blob - lib/remotes/git.js
7a67462a0c6e9baf010a7ea0ce6053520d899722
1 const { exec
} = require('child_process');
2 const { debuglog
, promisify
} = require('util');
5 // Promisified functions
8 debuglog: debuglog('blog'),
13 // For the future: actually check if it's a valid git url
17 async
syncUp(remote
, blogDirectory
) {
20 output
= await internals
.exec(`cd ${blogDirectory} && git init`);
21 internals
.debuglog(output
.stderr
);
23 output
= await internals
.exec(`cd ${blogDirectory} && git add .`);
24 internals
.debuglog(output
.stderr
);
26 output
= await internals
.exec(`cd ${blogDirectory} && git commit --allow-empty -m blog-sync-up-${Date.now()}`);
27 internals
.debuglog(output
.stderr
);
29 output
= await internals
.exec(`cd ${blogDirectory} && git push ${remote} main --force`);
30 internals
.debuglog(output
.stderr
);
33 async
syncDown(remote
, blogDirectory
) {
36 output
= await internals
.exec(`cd ${blogDirectory} && git init`);
37 internals
.debuglog(output
.stderr
);
39 output
= await internals
.exec(`cd ${blogDirectory} && git checkout .`);
40 internals
.debuglog(output
.stderr
);
42 output
= await internals
.exec(`cd ${blogDirectory} && git clean . -f`);
43 internals
.debuglog(output
.stderr
);
45 output
= await internals
.exec(`cd ${blogDirectory} && git pull ${remote} main`);
46 internals
.debuglog(output
.stderr
);