karte-expo-plugin
Version:
Config plugin for karte-react-native package
32 lines (31 loc) • 1.33 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.withKarteAndroid = void 0;
const config_plugins_1 = require("expo/config-plugins");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const withKarteAndroid = (config, props) => {
config = (0, config_plugins_1.withDangerousMod)(config, [
"android",
(config) => {
copyKarteXml(config, props);
return config;
},
]);
return config;
};
exports.withKarteAndroid = withKarteAndroid;
function copyKarteXml(config, props) {
if (!props.karteXml) {
throw new Error("Path to karte.xml is not defined. Please specify the `expo.android.karteXml` field in app.json.");
}
const xmlPath = path_1.default.resolve(config.modRequest.projectRoot, props.karteXml);
if (!fs_1.default.existsSync(xmlPath)) {
throw new Error(`karte.xml doesn't exist in ${xmlPath}. Place it there or configure the path in app.json`);
}
const destPath = path_1.default.resolve(config.modRequest.platformProjectRoot, "app/src/main/res/values/karte.xml");
fs_1.default.copyFileSync(xmlPath, destPath);
}