Skip to content

Commit a992a26

Browse files
committed
refactor: platform folder warning message
1 parent 611c296 commit a992a26

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/controllers/platform-controller.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,6 @@ export class PlatformController implements IPlatformController {
144144
path.join(projectData.platformsDir, platformName)
145145
);
146146

147-
if (hasPlatformDirectory) {
148-
const platformDirectoryItemCount = this.$fs.readDirectory(
149-
path.join(projectData.platformsDir, platformName)
150-
).length;
151-
152-
// 5 is a magic number to approximate a valid platform folder
153-
// any valid platform should contain at least 5 files
154-
// we choose 5 to avoid false-positives due to system files like .DS_Store etc.
155-
if (platformDirectoryItemCount <= 5) {
156-
this.$logger.warn(
157-
`The platforms/${platformName} folder appears to be invalid. If the build fails, run 'ns clean' and rebuild the app.`,
158-
{ wrapMessageWithBorders: true }
159-
);
160-
}
161-
}
162-
163147
const shouldAddNativePlatform =
164148
!nativePrepare || !nativePrepare.skipNativePrepare;
165149
const prepareInfo = this.$projectChangesService.getPrepareInfo(
@@ -169,11 +153,27 @@ export class PlatformController implements IPlatformController {
169153
prepareInfo &&
170154
prepareInfo.nativePlatformStatus ===
171155
NativePlatformStatus.requiresPlatformAdd;
172-
const result =
156+
const shouldAddPlatform =
173157
!hasPlatformDirectory ||
174158
(shouldAddNativePlatform && requiresNativePlatformAdd);
175159

176-
return !!result;
160+
if (hasPlatformDirectory && !shouldAddPlatform) {
161+
const platformDirectoryItemCount = this.$fs.readDirectory(
162+
path.join(projectData.platformsDir, platformName)
163+
).length;
164+
165+
// 3 is a magic number to approximate a valid platform folder
166+
// any valid platform should contain at least 3 files
167+
// we choose 3 to avoid false-positives due to system files like .DS_Store etc.
168+
if (platformDirectoryItemCount <= 3) {
169+
this.$logger.warn(
170+
`The platforms/${platformName} folder appears to be invalid. If the build fails, run 'ns clean' and rebuild the app.`,
171+
{ wrapMessageWithBorders: true }
172+
);
173+
}
174+
}
175+
176+
return !!shouldAddPlatform;
177177
}
178178
}
179179
injector.register("platformController", PlatformController);

0 commit comments

Comments
 (0)