Skip to content

Commit 99e5eb2

Browse files
committed
Fix unit tests
1 parent d36073c commit 99e5eb2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/services/platform-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,9 @@ export class PlatformService extends EventEmitter implements IPlatformService {
715715
let requiresNativePlatformAdd = false;
716716

717717
const platformData = this.$platformsData.getPlatformData(platform, projectData);
718+
const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
718719
// In case when no platform is added and webpack plugin is started it produces files in platforms folder. In this case {N} CLI needs to add platform and keeps the already produced files from webpack
719-
if (!this.$fs.exists(platformData.configurationFilePath) && this.isPlatformInstalled(platform, projectData) && appFilesUpdaterOptions.bundle) {
720+
if (appFilesUpdaterOptions.bundle && this.isPlatformInstalled(platform, projectData) && !this.$fs.exists(platformData.configurationFilePath) && prepareInfo.nativePlatformStatus !== constants.NativePlatformStatus.alreadyPrepared) {
720721
const tmpDirectoryPath = path.join(projectData.projectDir, "platforms", "tmp");
721722
this.$fs.deleteDirectory(tmpDirectoryPath);
722723
this.$fs.ensureDirectoryExists(tmpDirectoryPath);
@@ -731,7 +732,6 @@ export class PlatformService extends EventEmitter implements IPlatformService {
731732
await this.addPlatform(platform, platformTemplate, projectData, config, "", nativePrepare);
732733
} else {
733734
const shouldAddNativePlatform = !nativePrepare || !nativePrepare.skipNativePrepare;
734-
const prepareInfo = this.$projectChangesService.getPrepareInfo(platform, projectData);
735735
// In case there's no prepare info, it means only platform add had been executed. So we've come from CLI and we do not need to prepare natively.
736736
requiresNativePlatformAdd = prepareInfo && prepareInfo.nativePlatformStatus === constants.NativePlatformStatus.requiresPlatformAdd;
737737
if (requiresNativePlatformAdd && shouldAddNativePlatform) {

test/npm-support.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ function createTestInjector(): IInjector {
4949
testInjector.register("platformsData", PlatformsDataLib.PlatformsData);
5050
testInjector.register("platformService", PlatformServiceLib.PlatformService);
5151
testInjector.register("logger", stubs.LoggerStub);
52-
testInjector.register("npmInstallationManager", {});
52+
testInjector.register("npmInstallationManager", {
53+
install: () => Promise.resolve()
54+
});
5355
testInjector.register("prompter", {});
5456
testInjector.register("sysInfo", {});
5557
testInjector.register("androidProjectService", {});

0 commit comments

Comments
 (0)