MCPcopy
hub / github.com/zoontek/react-native-bootsplash / transformProps

Function transformProps

src/extras/utils.ts:288–433  ·  view source on GitHub ↗
(
  rootPath: string,
  { android = {}, licenseKey, ...rawProps }: BootSplashPluginConfig,
)

Source from the content-addressed store, hash-verified

286};
287
288export const transformProps = async (
289 rootPath: string,
290 { android = {}, licenseKey, ...rawProps }: BootSplashPluginConfig,
291) => {
292 if (semver.lt(process.versions.node, "20.0.0")) {
293 log.error("Requires Node 20 (or higher)");
294 process.exit(1);
295 }
296
297 const withDefaults = {
298 assetsOutput: "assets/bootsplash",
299 background: "#fff",
300 brandWidth: 80,
301 logoWidth: 100,
302 ...rawProps,
303 };
304
305 const assetsOutputPath = path.resolve(rootPath, withDefaults.assetsOutput);
306 const logoPath = path.resolve(rootPath, withDefaults.logo);
307
308 const darkLogoPath =
309 withDefaults.darkLogo != null
310 ? path.resolve(rootPath, withDefaults.darkLogo)
311 : undefined;
312
313 const brandPath =
314 withDefaults.brand != null
315 ? path.resolve(rootPath, withDefaults.brand)
316 : undefined;
317
318 const darkBrandPath =
319 withDefaults.darkBrand != null
320 ? path.resolve(rootPath, withDefaults.darkBrand)
321 : undefined;
322
323 const logoWidth = withDefaults.logoWidth - (withDefaults.logoWidth % 2);
324 const brandWidth = withDefaults.brandWidth - (withDefaults.brandWidth % 2);
325
326 const [logo, darkLogo, brand, darkBrand] = await Promise.all([
327 toAsset(logoPath, logoWidth),
328 darkLogoPath != null ? toAsset(darkLogoPath, logoWidth) : undefined,
329 brandPath != null ? toAsset(brandPath, brandWidth) : undefined,
330 darkBrandPath != null ? toAsset(darkBrandPath, brandWidth) : undefined,
331 ]);
332
333 const background = parseColor(withDefaults.background);
334
335 const darkBackground =
336 withDefaults.darkBackground != null
337 ? parseColor(withDefaults.darkBackground)
338 : undefined;
339
340 const executeAddon =
341 brand != null ||
342 darkBackground != null ||
343 darkLogo != null ||
344 darkBrand != null;
345

Callers 8

generateFunction · 0.90
withAndroidAssetsFunction · 0.90
withAndroidStylesFunction · 0.90
withAndroidColorsFunction · 0.90
withAndroidColorsNightFunction · 0.90
withIOSAssetsFunction · 0.90
withWebAssetsFunction · 0.90
withGenericAssetsFunction · 0.90

Calls 2

toAssetFunction · 0.85
parseColorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…