Skip to content

Commit 9f59e0c

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Remove platform command
1 parent 1a22a46 commit 9f59e0c

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

lib/bootstrap.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $injector.require("platformService", "./services/platform-service");
1515
$injector.requireCommand("create", "./commands/create-project");
1616
$injector.requireCommand("platform|*list", "./commands/list-platforms");
1717
$injector.requireCommand("platform|add", "./commands/add-platform");
18+
$injector.requireCommand("platform|remove", "./commands/remove-platform");
1819
$injector.requireCommand("run", "./commands/run");
1920
$injector.requireCommand("prepare", "./commands/prepare");
2021
$injector.requireCommand("build", "./commands/build");

lib/commands/remove-platform.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="../.d.ts"/>
2+
3+
export class RemovePlatformCommand implements ICommand {
4+
constructor(private $platformService: IPlatformService) { }
5+
6+
execute(args: string[]): IFuture<void> {
7+
return (() => {
8+
this.$platformService.removePlatforms(args).wait();
9+
}).future<void>()();
10+
}
11+
}
12+
$injector.registerCommand("platform|remove", RemovePlatformCommand);

lib/definitions/platform.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface IPlatformService {
55
runPlatform(platform: string): IFuture<void>;
66
preparePlatform(platform: string): IFuture<void>;
77
buildPlatform(platform: string): IFuture<void>;
8+
removePlatforms(platforms: string[]): IFuture<void>;
89
}
910

1011
interface IPlatformData {

lib/services/platform-service.ts

+16
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,22 @@ export class PlatformService implements IPlatformService {
162162
}).future<void>()();
163163
}
164164

165+
public removePlatforms(platforms: string[]): IFuture<void> {
166+
return (() => {
167+
if(!platforms || platforms.length === 0) {
168+
this.$errors.fail("No platform specified. Please specify a platform to remove");
169+
}
170+
171+
_.each(platforms, platform => {
172+
this.validatePlatformInstalled(platform);
173+
174+
var platformDir = path.join(this.$projectData.platformsDir, platform);
175+
this.$fs.deleteDirectory(platformDir).wait();
176+
});
177+
178+
}).future<void>()();
179+
}
180+
165181
private validatePlatform(platform: string): void {
166182
if (!this.isValidPlatform(platform)) {
167183
this.$errors.fail("Invalid platform %s. Valid platforms are %s.", platform, helpers.formatListOfNames(this.$platformsData.platformsNames));

resources/help.txt

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ General commands:
99
create Creates a new NativeScript project with given project name and application identifier.
1010
platform add Creates a new platform specific project.
1111
platform list Lists all available and all installed platforms.
12+
platform remove Removes the platform specific project.
1213
prepare Copies files for specified platform, so that the project is ready to build in platform specific SDK.
1314
build Builds the project for the selected target platform and produces an application package.
1415
run This is shorthand for prepare and build.
@@ -81,6 +82,20 @@ Platform-specific usage:
8182

8283
Creates a new platform specific project. In this version of Telerik NativeScript you can create only ios and android projects.
8384
You can create Android projects on windows and Mac machine. You can create ios projects only on Mac machine.
85+
86+
--[/]--
87+
88+
--[platform|remove]--
89+
90+
Usage:
91+
$ tns platform remove <platform>
92+
93+
Platform-specific usage:
94+
$ tns platform remove android
95+
$ tns platform remove ios
96+
97+
Removes the platform specific project.
98+
8499
--[/]--
85100

86101
--[prepare]--

0 commit comments

Comments
 (0)