UNPKG

rn-logo-replacer

Version:

This is a project aiming at remplacing the logo of a react native app with a single npx command

56 lines (55 loc) 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = execute; const operation_1 = require("../../../file_actions_obj/operation"); const copy_1 = require("./copy"); const delete_1 = require("./delete"); const move_1 = require("./move"); const pathValidator_1 = require("../pathValidator"); const platform_1 = require("../platform"); const destination_1 = require("../destination"); function execute(platform, operation, source, destination) { if (isNullOrEmpty(source)) { console.error(`Variable source is null or empty.`); process.exit(1); } // This step validated if the icons paths are in the source folder or not const sources = (0, pathValidator_1.validatedIconPath)(source, platform); sources.forEach((sourcesSubPaths, platformInSource) => { let iconsDestination = destination; if (isNullOrEmpty(destination)) { if (platformInSource == platform_1.Platform.Android) { iconsDestination = destination_1.defaultRNDestination.Android; } if (platformInSource == platform_1.Platform.Ios) { iconsDestination = destination_1.defaultRNDestination.Ios; } } console.log(`platformInSource : ${platformInSource} => sourcesSubPaths: ${sourcesSubPaths} destination : ${iconsDestination} `); sourcesSubPaths.forEach(sourcesSubPath => { if (operation == operation_1.Operation.Copy) { (0, copy_1.executeCopy)(sourcesSubPath, iconsDestination, platformInSource); } else if (operation == operation_1.Operation.Move) { (0, move_1.executeMove)(sourcesSubPath, iconsDestination, platformInSource); } else if (operation == operation_1.Operation.Delete) { (0, delete_1.executeDelete)(sourcesSubPath, platformInSource); } else { let list_operation = ""; for (let op in operation_1.Operation) { list_operation += operation_1.Operation[op] + '\n\t'; } console.error(`The operation ${operation} is not a valid one.\n\t${list_operation}`); process.exit(1); } }); }); } function isNullOrEmpty(value) { return value === null || value === undefined || value === ""; }