Skip to content
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

fix(assets-generation): Do not fail in case some App_Resources are missing #3557

Merged
merged 1 commit into from
May 2, 2018

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented May 2, 2018

In case you delete App_Resources/iOS directory, the getAssetsStructure method fails as it tries to read Content.json files from the deleted directory. Instead of failing, just return empty arrays for the images. This is already working this way for Android.
Add test for the case

PR Checklist

What is the current behavior?

Trying to generate/get assets structure fails when App_Resources/iOS is deleted

What is the new behavior?

The generation of assets will work for Android in this case.

Fixes ProgressNS/sidekick-feedback#168 .

…ssing

In case you delete `App_Resources/iOS` directory, the `getAssetsStructure` method fails as it tries to read `Content.json` files from the deleted directory. Instead of failing, just return empty arrays for the images. This is already working this way for Android.
Add test for the case
@rosen-vladimirov rosen-vladimirov added this to the 4.0.1 milestone May 2, 2018
@rosen-vladimirov rosen-vladimirov self-assigned this May 2, 2018
@rosen-vladimirov rosen-vladimirov requested a review from Fatme May 2, 2018 11:15
@rosen-vladimirov rosen-vladimirov changed the title fix(assets-generation): Do not fail in case some App_Resources are mi… fix(assets-generation): Do not fail in case some App_Resources are missing May 2, 2018
@@ -125,7 +125,7 @@ export class ProjectDataService implements IProjectDataService {

private async getIOSAssetSubGroup(dirPath: string): Promise<IAssetSubGroup> {
const pathToContentJson = path.join(dirPath, AssetConstants.iOSResourcesFileName);
const content = <IAssetSubGroup>this.$fs.readJson(pathToContentJson);
const content = this.$fs.exists(pathToContentJson) && <IAssetSubGroup>this.$fs.readJson(pathToContentJson) || { images: [] };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen in case when pathToContentJson exists but the file is not a valid json? I'm expecting to throw an error in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I prefer to throw the error in this case as it is not expected to have a non-json file here.

const fs = testInjector.resolve<IFileSystem>("fs");
fs.readJson = (filePath: string): any => {
if (basename(filePath) === AssetConstants.imageDefinitionsFileName) {
return { android: {}, ios: {} };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case when imageDefinitionsFileName file does not exist, an error will be thrown. I'm wondering if we should check this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is part of CLI resources, so in case it does not exist, something terrible happened 😸

@rosen-vladimirov rosen-vladimirov merged commit 238eb06 into release May 2, 2018
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-assets-structure branch May 2, 2018 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants