react-native-integrate
Version:
Automate integration of additional code into React Native projects
30 lines (29 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handlePackageUpgradeInput = handlePackageUpgradeInput;
exports.getLastInputValue = getLastInputValue;
const variables_1 = require("../variables");
const packageUpgradeConfig_1 = require("./packageUpgradeConfig");
function handlePackageUpgradeInput(packageName, inputName) {
const isUpgrade = variables_1.variables.get('__UPGRADE__') == true;
if (!isUpgrade)
return false;
const inputValue = getLastInputValue(packageName, inputName);
if (inputValue == null)
return false;
// set input value to variables
variables_1.variables.set(inputName, inputValue);
return true;
}
function getLastInputValue(packageName, inputName) {
// get from .upgrade folder
const packageUpgradeConfig = (0, packageUpgradeConfig_1.getPackageUpgradeConfig)(packageName);
// check if input is defined
if (!packageUpgradeConfig.inputs)
return null;
const inputValue = packageUpgradeConfig.inputs[inputName];
// check if input has value
if (inputValue == null)
return null;
return inputValue;
}