UNPKG

@armanatz/expo-hms-location

Version:

Expo config plugin to configure @hmscore/react-native-hms-location on prebuild

36 lines (35 loc) 1.55 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports._copyAGConnectServicesFile = _copyAGConnectServicesFile; exports.default = withAGConnectServicesFile; const config_plugins_1 = require("expo/config-plugins"); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); async function _copyAGConnectServicesFile(projectRoot, platformProjectRoot, agConnectServicesFile) { let filePathToRead = agConnectServicesFile; if (agConnectServicesFile.startsWith('.', 0)) { filePathToRead = path_1.default.join(projectRoot, agConnectServicesFile); } const filePathToWrite = path_1.default.join(platformProjectRoot, 'app', `agconnect-services.json`); if (!fs_1.default.existsSync(filePathToWrite)) { try { const fileContents = await fs_1.default.promises.readFile(filePathToRead, 'utf-8'); await fs_1.default.promises.writeFile(filePathToWrite, fileContents); } catch (error) { throw error; } } } function withAGConnectServicesFile(config, agConnectServicesFile) { return (0, config_plugins_1.withDangerousMod)(config, [ 'android', async (config) => { await _copyAGConnectServicesFile(config.modRequest.projectRoot, config.modRequest.platformProjectRoot, agConnectServicesFile); return config; }, ]); }