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