UNPKG

607 BJavaScriptView Raw
1const findKey = require('lodash/findKey');
2
3const reverseInsts = {
4 'createFile': 'deleteFile',
5 'appendFile': 'detachFromFile',
6 'updateFile': 'rollbackFile',
7 'updateJSONFile': 'rollbackJSONFile',
8 'installDependency': 'removeDependency',
9 'runShellCommand': 'undoShellCommand'
10};
11
12const equal = (value) => {
13 return (v) => v === value;
14};
15
16const findReverseInst = (name) => {
17 return reverseInsts[name] || findKey(reverseInsts, equal(name)) || name;
18};
19
20const reverseInstruction = ({ name, params }) => {
21 return { name: findReverseInst(name), params };
22};
23
24module.exports = reverseInstruction;