@@ -84,15 +84,37 @@ const removeDuplicateCommands = <T extends boolean>(commands: Command<T>[]) => {
8484 return Array . from ( uniqueCommandsMap . values ( ) ) ;
8585} ;
8686
87+ /**
88+ * Returns the built-in platforms to seed the config with, honoring the
89+ * `selectedPlatform` filter the same way dependency platforms are filtered. The
90+ * project's own and dependencies' platforms are layered on top of these.
91+ */
92+ const getBasePlatforms = (
93+ platforms : Config [ 'platforms' ] | undefined ,
94+ selectedPlatform : string | undefined ,
95+ ) : { [ platform : string ] : Config [ 'platforms' ] [ string ] } => {
96+ if ( ! platforms ) {
97+ return { } ;
98+ }
99+ if ( selectedPlatform != null ) {
100+ return platforms [ selectedPlatform ]
101+ ? { [ selectedPlatform ] : platforms [ selectedPlatform ] }
102+ : { } ;
103+ }
104+ return platforms ;
105+ } ;
106+
87107/**
88108 * Loads CLI configuration
89109 */
90110export default function loadConfig ( {
91111 projectRoot = findProjectRoot ( ) ,
92112 selectedPlatform,
113+ platforms,
93114} : {
94115 projectRoot ?: string ;
95116 selectedPlatform ?: string ;
117+ platforms ?: Config [ 'platforms' ] ;
96118} ) : Config {
97119 let lazyProject : ProjectConfig ;
98120 const userConfig = readConfigFromDisk ( projectRoot ) ;
@@ -110,7 +132,10 @@ export default function loadConfig({
110132 dependencies : userConfig . dependencies ,
111133 commands : userConfig . commands ,
112134 healthChecks : userConfig . healthChecks || [ ] ,
113- platforms : userConfig . platforms ,
135+ platforms : {
136+ ...getBasePlatforms ( platforms , selectedPlatform ) ,
137+ ...userConfig . platforms ,
138+ } ,
114139 assets : userConfig . assets ,
115140 get project ( ) {
116141 if ( lazyProject ) {
@@ -188,9 +213,11 @@ export default function loadConfig({
188213export async function loadConfigAsync ( {
189214 projectRoot = findProjectRoot ( ) ,
190215 selectedPlatform,
216+ platforms,
191217} : {
192218 projectRoot ?: string ;
193219 selectedPlatform ?: string ;
220+ platforms ?: Config [ 'platforms' ] ;
194221} ) : Promise < Config > {
195222 let lazyProject : ProjectConfig ;
196223 const userConfig = await readConfigFromDiskAsync ( projectRoot ) ;
@@ -208,7 +235,10 @@ export async function loadConfigAsync({
208235 dependencies : userConfig . dependencies ,
209236 commands : userConfig . commands ,
210237 healthChecks : userConfig . healthChecks || [ ] ,
211- platforms : userConfig . platforms ,
238+ platforms : {
239+ ...getBasePlatforms ( platforms , selectedPlatform ) ,
240+ ...userConfig . platforms ,
241+ } ,
212242 assets : userConfig . assets ,
213243 get project ( ) {
214244 if ( lazyProject ) {
0 commit comments