Skip to content

Commit ebd336c

Browse files
committed
Merge pull request #19 from NativeScript/fatme/remove-platform-command
Remove platform command
2 parents fe6ea2c + 9f59e0c commit ebd336c

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
@@ -167,6 +167,22 @@ export class PlatformService implements IPlatformService {
167167
}).future<void>()();
168168
}
169169

170+
public removePlatforms(platforms: string[]): IFuture<void> {
171+
return (() => {
172+
if(!platforms || platforms.length === 0) {
173+
this.$errors.fail("No platform specified. Please specify a platform to remove");
174+
}
175+
176+
_.each(platforms, platform => {
177+
this.validatePlatformInstalled(platform);
178+
179+
var platformDir = path.join(this.$projectData.platformsDir, platform);
180+
this.$fs.deleteDirectory(platformDir).wait();
181+
});
182+
183+
}).future<void>()();
184+
}
185+
170186
private validatePlatform(platform: string): void {
171187
if (!this.isValidPlatform(platform)) {
172188
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)