Skip to content
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
31 changes: 17 additions & 14 deletions packages/cli-plugin-metro/src/commands/bundle/assetCatalogIOS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import path from 'path';
import fs from 'fs-extra';
import fs from 'fs';
import type {AssetData} from 'metro';
import assetPathUtils from './assetPathUtils';

Expand All @@ -16,7 +16,7 @@ export function cleanAssetCatalog(catalogDir: string): void {
.readdirSync(catalogDir)
.filter((file) => file.endsWith('.imageset'));
for (const file of files) {
fs.removeSync(path.join(catalogDir, file));
fs.rmSync(path.join(catalogDir, file));
}
}

Expand Down Expand Up @@ -49,22 +49,25 @@ export function isCatalogAsset(asset: AssetData): boolean {
}

export function writeImageSet(imageSet: ImageSet): void {
fs.mkdirsSync(imageSet.basePath);
fs.mkdirSync(imageSet.basePath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@huntie This should have { recursive: true } to be equivalent to mkdirs.


for (const file of imageSet.files) {
const dest = path.join(imageSet.basePath, file.name);
fs.copyFileSync(file.src, dest);
}

fs.writeJSONSync(path.join(imageSet.basePath, 'Contents.json'), {
images: imageSet.files.map((file) => ({
filename: file.name,
idiom: 'universal',
scale: `${file.scale}x`,
})),
info: {
author: 'xcode',
version: 1,
},
});
fs.writeFileSync(
path.join(imageSet.basePath, 'Contents.json'),
JSON.stringify({
images: imageSet.files.map((file) => ({
filename: file.name,
idiom: 'universal',
scale: `${file.scale}x`,
})),
info: {
author: 'xcode',
version: 1,
},
}),
);
}