-const { readFile, rm, writeFile } = require('fs/promises');
+const { readFile, writeFile } = require('fs/promises');
+const { rmIfExists } = require('./utils');
const internals = {
strings: {
module.exports = {
async add(remoteConfig, remote) {
+
await writeFile(remoteConfig, remote);
},
async remove(remoteConfig) {
- await rm(remoteConfig, { force: true })
+
+ await rmIfExists(remoteConfig);
},
async syncUp(remoteConfig, blogDirectory) {
+
await this._executeMethodOnStrategy(remoteConfig, 'syncUp', blogDirectory);
},
async syncDown(remoteConfig, blogDirectory) {
+
await this._executeMethodOnStrategy(remoteConfig, 'syncDown', blogDirectory);
},
async _executeMethodOnStrategy(remoteConfig, method, blogDirectory) {
+
const remote = await this._ensureConfiguration(remoteConfig);
for (const strategy of internals.strategies) {
},
async _ensureConfiguration(remoteConfig) {
+
try {
const configuration = await readFile(remoteConfig, { encoding: 'utf8' });
return configuration;