X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/f91c2b4feb85933bc190712b45788d2f24fe851d..3c39d1553de92cd6cac891f2c3b186701ec60332:/lib/remote.js diff --git a/lib/remote.js b/lib/remote.js index 8b29c4e..ad0a4fc 100644 --- a/lib/remote.js +++ b/lib/remote.js @@ -1,15 +1,18 @@ -const { readFile, rm, writeFile } = require('fs/promises'); +import { readFile, writeFile } from 'fs/promises'; +import { rmIfExists } from './utils.js'; + +import GitStrategy from './remotes/git.js'; const internals = { strings: { configurationNotFound: 'Remote configuration not set, consult help for more info.' }, strategies: [ - require('./remotes/git') + GitStrategy ] }; -module.exports = { +export default { async add(remoteConfig, remote) { await writeFile(remoteConfig, remote); @@ -17,7 +20,7 @@ module.exports = { async remove(remoteConfig) { - await rm(remoteConfig, { force: true }) + await rmIfExists(remoteConfig); }, async syncUp(remoteConfig, blogDirectory) { @@ -51,4 +54,4 @@ module.exports = { throw new Error(internals.strings.configurationNotFound); } } -} +};