Skip to content

Commit

Permalink
feat: warn invalid platform folders (#5463)
Browse files Browse the repository at this point in the history
* feat: handle empty platforms folder

* chore: shorter warning message

Co-authored-by: Igor Randjelovic <rigor789@gmail.com>

* fix: platformDirectoryItemCount variable name

* chore: explaining platformDirectoryItemCount check

Co-authored-by: Igor Randjelovic <rigor789@gmail.com>

Co-authored-by: Igor Randjelovic <rigor789@gmail.com>
  • Loading branch information
janoshrubos and rigor789 authored Jan 26, 2021
1 parent bca6757 commit fde4403
Showing 1 changed file with 17 additions and 0 deletions.
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

0 comments on commit fde4403

Please sign in to comment.