UNPKG

karte-expo-plugin

Version:

Config plugin for karte-react-native package

41 lines (36 loc) 1.07 kB
import { ConfigPlugin, withDangerousMod, ExportedConfigWithProps, } from "expo/config-plugins"; import fs from "fs"; import path from "path"; import { ConfigProps } from "./types"; export const withKarteAndroid: ConfigPlugin<ConfigProps> = (config, props) => { config = withDangerousMod(config, [ "android", (config) => { copyKarteXml(config, props); return config; }, ]); return config; }; function copyKarteXml(config: ExportedConfigWithProps, props: ConfigProps) { 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.resolve(config.modRequest.projectRoot, props.karteXml); if (!fs.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.resolve( config.modRequest.platformProjectRoot, "app/src/main/res/values/karte.xml" ); fs.copyFileSync(xmlPath, destPath); }