( assets, platform, assetsDest )
| 17 | const path = require('path'); |
| 18 | |
| 19 | function saveAssets( |
| 20 | assets, |
| 21 | platform, |
| 22 | assetsDest |
| 23 | ) { |
| 24 | if (!assetsDest) { |
| 25 | console.warn('Assets destination folder is not set, skipping...'); |
| 26 | return Promise.resolve(); |
| 27 | } |
| 28 | |
| 29 | const getAssetDestPath = platform === 'android' |
| 30 | ? getAssetDestPathAndroid |
| 31 | : getAssetDestPathIOS; |
| 32 | |
| 33 | const filesToCopy = Object.create(null); // Map src -> dest |
| 34 | assets |
| 35 | .forEach(asset => |
| 36 | filterPlatformAssetScales(platform, asset.scales).forEach((scale, idx) => { |
| 37 | const src = asset.files[idx]; |
| 38 | const dest = path.join(assetsDest, getAssetDestPath(asset, scale)); |
| 39 | filesToCopy[src] = dest; |
| 40 | }) |
| 41 | ); |
| 42 | |
| 43 | return copyAll(filesToCopy); |
| 44 | } |
| 45 | |
| 46 | function copyAll(filesToCopy) { |
| 47 | const queue = Object.keys(filesToCopy); |
no test coverage detected
searching dependent graphs…