-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathactions.ts
More file actions
37 lines (32 loc) · 1.07 KB
/
actions.ts
File metadata and controls
37 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Action } from "../../typings";
import { ConnectionConfiguration } from "../Configuration";
import IBMi from "../IBMi";
import { ConfigFile } from "./configFile";
export function getActionsConfig(connection: IBMi) {
const ActionsConfig = new ConfigFile<Action[]>(connection, `actions`);
ActionsConfig.hasServerFile = true;
ActionsConfig.mergeArrays = true;
ActionsConfig.validateAndCleanInPlace = (loadedConfig) => {
let actions: Action[] = [];
// Maybe one day replace this with real schema validation
if (Array.isArray(loadedConfig)) {
loadedConfig.forEach((action, index) => {
if (
typeof action.name === `string` &&
typeof action.command === `string` &&
[`ile`, `pase`, `qsh`].includes(action.environment) &&
Array.isArray(action.extensions)
) {
actions.push({
type: `file`,
...action,
});
} else {
throw new Error(`Invalid Action defined at index ${index}.`);
}
})
}
return actions;
}
return ActionsConfig;
}