Skip to content

Commit 25f63c3

Browse files
ivanovitrosen-vladimirov
authored andcommitted
Add platform parameter
1 parent 5493cef commit 25f63c3

File tree

3 files changed

+123
-61
lines changed

3 files changed

+123
-61
lines changed

lib/declarations.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,11 @@ interface IResourceGenerationData {
807807
/**
808808
* @param {string} resourcesPath Path to the app resources
809809
*/
810-
resourcesPath: string
810+
resourcesPath: string,
811+
/**
812+
* @param {string} platform Specify for which platform to generate assets. If not defined will generate for all platforms
813+
*/
814+
platform?: string
811815
}
812816

813817
/**

lib/services/assets-generation/assets-generation-service.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ export class AssetsGenerationService implements IAssetsGenerationService {
1212
@exported("assetsGenerationService")
1313
public async generateIcons(resourceGenerationData: IResourceGenerationData): Promise<void> {
1414
this.$logger.info("Generating icons ...");
15-
await this.generateImagesForDefinitions(resourceGenerationData.imagePath, resourceGenerationData.resourcesPath, Icons);
15+
await this.generateImagesForDefinitions(resourceGenerationData.imagePath, resourceGenerationData.resourcesPath, Icons, resourceGenerationData.platform);
1616
this.$logger.info("Icons generation completed.");
1717
}
1818

1919
@exported("assetsGenerationService")
2020
public async generateSplashScreens(splashesGenerationData: ISplashesGenerationData): Promise<void> {
2121
this.$logger.info("Generating splash screens ...");
22-
await this.generateImagesForDefinitions(splashesGenerationData.imagePath, splashesGenerationData.resourcesPath, SplashScreens, splashesGenerationData.background);
22+
await this.generateImagesForDefinitions(splashesGenerationData.imagePath, splashesGenerationData.resourcesPath, SplashScreens, splashesGenerationData.platform, splashesGenerationData.background);
2323
this.$logger.info("Splash screens generation completed.");
2424
}
2525

26-
private async generateImagesForDefinitions(imagePath: string, resourcesPath: string, definitions: any[], background: string = "white") : Promise<void> {
26+
private async generateImagesForDefinitions(imagePath: string, resourcesPath: string, definitions: any[], platform?: string, background: string = "white") : Promise<void> {
2727
const hasMigrated = this.$androidResourcesMigrationService.hasMigrated(resourcesPath);
2828

29-
for (const definition of definitions) {
29+
const filteredDefinitions = platform ? _.filter(definitions, definition => _.toLower(definition.platform) === _.toLower(platform)) : definitions;
30+
31+
for (const definition of filteredDefinitions) {
3032
const operation = definition.operation || Operations.Resize;
3133
const scale = definition.scale || 0.8;
3234
const path = hasMigrated ? definition.path : (definition.pathBeforeMigration || definition.path);

0 commit comments

Comments
 (0)