Skip to content

feat: handle empty platforms folder #5463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/controllers/platform-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ export class PlatformController implements IPlatformController {
const hasPlatformDirectory = this.$fs.exists(
path.join(projectData.platformsDir, platformName)
);

if (hasPlatformDirectory) {
const platformDirectoryItemCount = this.$fs.readDirectory(
path.join(projectData.platformsDir, platformName)
).length;

// 5 is a magic number to approximate a valid platform folder
// any valid platform should contain at least 5 files
// we choose 5 to avoid false-positives due to system files like .DS_Store etc.
if (platformDirectoryItemCount <= 5) {
this.$logger.warn(
`The platforms/${platformName} folder appears to be invalid. If the build fails, run 'ns clean' and rebuild the app.`,
{ wrapMessageWithBorders: true }
);
}
}

const shouldAddNativePlatform =
!nativePrepare || !nativePrepare.skipNativePrepare;
const prepareInfo = this.$projectChangesService.getPrepareInfo(
Expand Down