Skip to content

Commit 249576e

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fix plugin remove, mock androidToolsInfo and adress some PR comments
1 parent bca245a commit 249576e

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

lib/services/ios-project-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
124124
let infoPlistFilePath = path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, util.format("%s-%s", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER, "Info.plist"));
125125
this.interpolateConfigurationFile(infoPlistFilePath).wait();
126126

127-
this.replaceFileName("-Info.plist", path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER)).wait();
128-
this.replaceFileName("-Prefix.pch", path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER)).wait();
127+
let projectRootFilePath = path.join(this.platformData.projectRoot, IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER);
128+
this.replaceFileName("-Info.plist", projectRootFilePath).wait();
129+
this.replaceFileName("-Prefix.pch", projectRootFilePath).wait();
129130
this.replaceFileName(IOSProjectService.XCODE_PROJECT_EXT_NAME, this.platformData.projectRoot).wait();
130131

131132
let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "project.pbxproj");

lib/services/plugins-service.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class PluginsService implements IPluginsService {
7575
// Remove the plugin and call merge for another plugins that have configuration file
7676
let pluginConfigurationFilePath = this.getPluginConfigurationFilePath(pluginData, platformData);
7777
if(this.$fs.exists(pluginConfigurationFilePath).wait()) {
78-
this.merge(pluginData, platformData).wait();
78+
this.merge(pluginData, platformData, (data: IPluginData) => data.name !== pluginData.name).wait();
7979
}
8080

8181
if(pluginData.pluginVariables) {
@@ -340,12 +340,13 @@ export class PluginsService implements IPluginsService {
340340
}).future<void>()();
341341
}
342342

343-
private merge(pluginData: IPluginData, platformData: IPlatformData): IFuture<void> {
343+
private merge(pluginData: IPluginData, platformData: IPlatformData, mergeCondition?: (_pluginData: IPluginData) => boolean): IFuture<void> {
344344
return (() => {
345345
let tnsModulesDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, constants.TNS_MODULES_FOLDER_NAME);
346346
let nodeModules = this.$broccoliBuilder.getChangedNodeModules(tnsModulesDestinationPath, platformData.normalizedPlatformName.toLowerCase()).wait();
347347

348-
_(_.keys(nodeModules))
348+
_(nodeModules)
349+
.keys()
349350
.map(nodeModule => this.getNodeModuleData(path.join(nodeModule, "package.json")).wait())
350351
.map(nodeModuleData => this.convertToPluginData(nodeModuleData))
351352
.filter(data => data.isPlugin && this.$fs.exists(this.getPluginConfigurationFilePath(data, platformData)).wait())
@@ -354,7 +355,9 @@ export class PluginsService implements IPluginsService {
354355
this.initializeConfigurationFileFromCache(platformData).wait();
355356
}
356357

357-
this.mergeCore(data, platformData).wait();
358+
if(!mergeCondition || (mergeCondition && mergeCondition(data))) {
359+
this.mergeCore(data, platformData).wait();
360+
}
358361
})
359362
.value();
360363

test/plugins-service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,16 @@ describe("Plugins service", () => {
586586
let projectData = testInjector.resolve("projectData");
587587
projectData.projectId = "com.example.android.basiccontactables";
588588

589+
// Mock androidTools
590+
let androidToolsInfo = testInjector.resolve("androidToolsInfo");
591+
androidToolsInfo.getToolsInfo = () => {
592+
return (() => {
593+
return {
594+
compileSdkVersion: "23"
595+
};
596+
}).future<IAndroidToolsInfoData>()();
597+
};
598+
589599
// Ensure the pluginDestinationPath folder exists
590600
let pluginPlatformsDirPath = path.join(projectFolder, "node_modules", pluginName, "platforms", "android");
591601
fs.ensureDirectoryExists(pluginPlatformsDirPath).wait();

0 commit comments

Comments
 (0)