Skip to content

Commit 0472afb

Browse files
chore: fix regexp when removing platforms section
When removing platforms section, fix the regexp, so the removal procedure will keep the file the same as before the platform section was added. Currently, after removing the platform section, the file had additional empty lines inside it.
1 parent d15a6da commit 0472afb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/services/cocoapods-platform-manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class CocoaPodsPlatformManager implements ICocoaPodsPlatformManager {
2626
const allPodfiles = projectPodfileContent.match(podfileContentRegExp) || [];
2727
const selectedPlatformData = this.selectPlatformDataFromProjectPodfile(allPodfiles);
2828
const newPlatformSection = selectedPlatformData ? this.buildPlatformSection(selectedPlatformData) : "";
29-
const regExp = new RegExp(`${platformSectionData.platformSectionContent}`, "mg");
29+
const regExp = new RegExp(`\\r?\\n${platformSectionData.platformSectionContent}\\r?\\n`, "mg");
3030
projectPodfileContent = projectPodfileContent.replace(regExp, newPlatformSection);
3131
}
3232

test/ios-project-service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ describe("Cocoapods support", () => {
386386

387387
projectData.podfilePath = basePodfilePath;
388388

389-
cocoapodsService.applyPodfileToProject(basePodfileModuleName, basePodfilePath, projectData, iOSProjectService.getPlatformData(projectData).projectRoot);
389+
await cocoapodsService.applyPodfileToProject(basePodfileModuleName, basePodfilePath, projectData, iOSProjectService.getPlatformData(projectData).projectRoot);
390390

391391
const projectPodfilePath = path.join(platformsFolderPath, "Podfile");
392-
assert.isTrue(fs.exists(projectPodfilePath));
392+
assert.isTrue(fs.exists(projectPodfilePath), `File ${projectPodfilePath} must exist as we have already applied Podfile to it.`);
393393

394394
const actualProjectPodfileContent = fs.readText(projectPodfilePath);
395395
const expectedPluginPodfileContent = ["source 'https://github.com/CocoaPods/Specs.git'", "# platform :ios, '8.1'", "pod 'GoogleMaps'"].join("\n");
@@ -410,8 +410,8 @@ describe("Cocoapods support", () => {
410410

411411
fs.deleteFile(basePodfilePath);
412412

413-
cocoapodsService.applyPodfileToProject(basePodfileModuleName, basePodfilePath, projectData, iOSProjectService.getPlatformData(projectData).projectRoot);
414-
assert.isFalse(fs.exists(projectPodfilePath));
413+
await cocoapodsService.applyPodfileToProject(basePodfileModuleName, basePodfilePath, projectData, iOSProjectService.getPlatformData(projectData).projectRoot);
414+
assert.isFalse(fs.exists(projectPodfilePath), `The projectPodfilePath (${projectPodfilePath}) must not exist when all Podfiles have been deleted and project is prepared again. (i.e. CLI should delete the project Podfile in this case)`);
415415
});
416416

417417
it("adds plugin with Podfile", async () => {

0 commit comments

Comments
 (0)