diff --git a/server/config.js b/server/config.js index 78525d63..a703856a 100644 --- a/server/config.js +++ b/server/config.js @@ -28,10 +28,12 @@ const HOME = require('os-homedir')(); const manageConfig = squad(traverse, cryptoPass); const save = promisify(_save); const swap = currify((f, a, b) => f(b, a)); +const noArgs = (fn) => () => fn(); +const saveData = noArgs(save); const sendError = swap(ponse.sendError); const send = swap(ponse.send); -const formatMsg = currify(CloudFunc.formatMsg); +const formatMsg = currify((a, b) => CloudFunc.formatMsg(a, b)); const apiURL = CloudFunc.apiURL; @@ -166,14 +168,12 @@ function patch(req, res) { cache : false }; - const saveData = wraptile(save); - pullout(req, 'string') .then(jonny.parse) .then(jsonStore) .then(manageConfig) .then(saveData) - .then(jsonStore) + .then(noArgs(jsonStore)) .then(key) .then(formatMsg('config')) .then(send(options)) diff --git a/test/rest/config.js b/test/rest/config.js index 2e340fd5..09609492 100644 --- a/test/rest/config.js +++ b/test/rest/config.js @@ -137,12 +137,13 @@ test('cloudcmd: rest: config: patch: save config', (t) => { editor: 'dword', }; - let originalConfig = readjson.sync.try(pathConfig); + const originalConfig = readjson.sync.try(pathConfig); patch(`http://localhost:${port}/api/v1/config`, json) .then(warp(_pullout, 'string')) .then(() => { const config = readjson.sync(pathConfig); + t.equal(config.editor, 'dword', 'should change config file on patch'); t.end();