fix(config) patch

This commit is contained in:
coderaiser 2017-12-04 18:32:08 +02:00
parent 53d79bfda8
commit af70eb5ee6
2 changed files with 6 additions and 5 deletions

View file

@ -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))

View file

@ -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();