-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlist-platforms.ts
32 lines (26 loc) · 1.3 KB
/
list-platforms.ts
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
import * as helpers from "../common/helpers";
export class ListPlatformsCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(private $platformService: IPlatformService,
private $projectData: IProjectData,
private $logger: ILogger) {
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
const installedPlatforms = this.$platformService.getInstalledPlatforms(this.$projectData);
if (installedPlatforms.length > 0) {
const preparedPlatforms = this.$platformService.getPreparedPlatforms(this.$projectData);
if (preparedPlatforms.length > 0) {
this.$logger.info("The project is prepared for: ", helpers.formatListOfNames(preparedPlatforms, "and"));
} else {
this.$logger.info("The project is not prepared for any platform");
}
this.$logger.info("Installed platforms: ", helpers.formatListOfNames(installedPlatforms, "and"));
} else {
const formattedPlatformsList = helpers.formatListOfNames(this.$platformService.getAvailablePlatforms(this.$projectData), "and");
this.$logger.info("Available platforms for this OS: ", formattedPlatformsList);
this.$logger.info("No installed platforms found. Use $ tns platform add");
}
}
}
$injector.registerCommand("platform|*list", ListPlatformsCommand);