Skip to content

Commit e971e1f

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fixes #1027
1 parent d5d3c99 commit e971e1f

File tree

4 files changed

+24
-27
lines changed

4 files changed

+24
-27
lines changed

lib/definitions/plugins.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interface IPluginsService {
22
add(plugin: string): IFuture<void>; // adds plugin by name, github url, local path and et.
33
remove(pluginName: string): IFuture<void>; // removes plugin only by name
4-
prepare(pluginData: IDependencyData): IFuture<void>;
4+
prepare(pluginData: IDependencyData, platform: string): IFuture<void>;
55
getAllInstalledPlugins(): IFuture<IPluginData[]>;
66
ensureAllDependenciesAreInstalled(): IFuture<void>;
77
afterPrepareAllPlugins(): IFuture<void>;

lib/services/plugins-service.ts

+21-24
Original file line numberDiff line numberDiff line change
@@ -122,40 +122,37 @@ export class PluginsService implements IPluginsService {
122122
}).future<void>()();
123123
}
124124

125-
public prepare(dependencyData: IDependencyData): IFuture<void> {
125+
public prepare(dependencyData: IDependencyData, platform: string): IFuture<void> {
126126
return (() => {
127+
platform = platform.toLowerCase();
128+
let platformData = this.$platformsData.getPlatformData(platform);
129+
let pluginDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, "tns_modules");
127130
let pluginData = this.convertToPluginData(dependencyData);
128131

129-
let action = (pluginDestinationPath: string, platform: string, platformData: IPlatformData) => {
130-
return (() => {
131-
if(!this.isPluginDataValidForPlatform(pluginData, platform).wait()) {
132-
return;
133-
}
132+
if(!this.isPluginDataValidForPlatform(pluginData, platform).wait()) {
133+
return;
134+
}
134135

135-
if(this.$fs.exists(path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME)).wait()) {
136-
this.$fs.ensureDirectoryExists(pluginDestinationPath).wait();
137-
shelljs.cp("-Rf", pluginData.fullPath, pluginDestinationPath);
136+
if(this.$fs.exists(path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME)).wait()) {
137+
this.$fs.ensureDirectoryExists(pluginDestinationPath).wait();
138+
shelljs.cp("-Rf", pluginData.fullPath, pluginDestinationPath);
138139

139-
let pluginConfigurationFilePath = this.getPluginConfigurationFilePath(pluginData, platformData);
140-
if(this.$fs.exists(pluginConfigurationFilePath).wait()) {
141-
this.merge(pluginData, platformData).wait();
142-
}
140+
let pluginConfigurationFilePath = this.getPluginConfigurationFilePath(pluginData, platformData);
143141

144-
this.$projectFilesManager.processPlatformSpecificFiles(pluginDestinationPath, platform).wait();
142+
if(this.$fs.exists(pluginConfigurationFilePath).wait()) {
143+
this.merge(pluginData, platformData).wait();
144+
}
145145

146-
pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform);
147-
platformData.platformProjectService.preparePluginNativeCode(pluginData).wait();
146+
this.$projectFilesManager.processPlatformSpecificFiles(pluginDestinationPath, platform).wait();
148147

149-
shelljs.rm("-rf", path.join(pluginDestinationPath, pluginData.name, "platforms"));
148+
pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform);
149+
platformData.platformProjectService.preparePluginNativeCode(pluginData).wait();
150150

151-
// Show message
152-
this.$logger.out(`Successfully prepared plugin ${pluginData.name} for ${platform}.`);
153-
}
151+
shelljs.rm("-rf", path.join(pluginDestinationPath, pluginData.name, "platforms"));
154152

155-
}).future<void>()();
156-
};
157-
158-
this.executeForAllInstalledPlatforms(action).wait();
153+
// Show message
154+
this.$logger.out(`Successfully prepared plugin ${pluginData.name} for ${platform}.`);
155+
}
159156
}).future<void>()();
160157
}
161158

lib/tools/broccoli/node-modules-dest-copy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class DestCopy implements IBroccoliPlugin {
7474

7575
let isPlugin = !!dependency.nativescript;
7676
if(isPlugin) {
77-
this.$pluginsService.prepare(dependency).wait();
77+
this.$pluginsService.prepare(dependency, platform).wait();
7878
}
7979

8080
if (dependency.name === constants.TNS_CORE_MODULES_NAME) {

0 commit comments

Comments
 (0)