Skip to content

Commit fde4403

Browse files
feat: warn invalid platform folders (#5463)
* feat: handle empty platforms folder * chore: shorter warning message Co-authored-by: Igor Randjelovic <[email protected]> * fix: platformDirectoryItemCount variable name * chore: explaining platformDirectoryItemCount check Co-authored-by: Igor Randjelovic <[email protected]> Co-authored-by: Igor Randjelovic <[email protected]>
1 parent bca6757 commit fde4403

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/controllers/platform-controller.ts

+17
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,23 @@ export class PlatformController implements IPlatformController {
143143
const hasPlatformDirectory = this.$fs.exists(
144144
path.join(projectData.platformsDir, platformName)
145145
);
146+
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+
146163
const shouldAddNativePlatform =
147164
!nativePrepare || !nativePrepare.skipNativePrepare;
148165
const prepareInfo = this.$projectChangesService.getPrepareInfo(

0 commit comments

Comments
 (0)