forked from redhat-developer/vscode-openshift-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandResolver.ts
More file actions
29 lines (23 loc) · 1.02 KB
/
Copy pathcommandResolver.ts
File metadata and controls
29 lines (23 loc) · 1.02 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
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import { Command, Data } from '../odo/componentTypeDescription';
export class CommandResolver {
public static getCommand(devfile: Data, commandId: string): Command {
const command = devfile.commands.find(
(c) => c.id.toLowerCase() === commandId.toLowerCase(),
);
if (!command) {
throw new Error(`Command '${commandId}' not found`);
}
return command;
}
public static getAllCommandsMap(devfile: Data): Map<string, Command> {
const map = new Map<string, Command>();
for (const command of devfile.commands) {
map.set(command.id.toLowerCase(), command);
}
return map;
}
}