UNPKG

@armanatz/expo-hms-location

Version:

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

37 lines (36 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.appendContents = appendContents; /** * Forked from expo-camera * * Sourcecode: https://github.com/expo/expo/blob/253619d08eff5a8674405fe6608ead2ab086f3d5/packages/expo-camera/plugin/src/appendCode.ts * LICENSE: https://github.com/expo/expo/blob/253619d08eff5a8674405fe6608ead2ab086f3d5/LICENSE */ const generateCode_1 = require("./generateCode"); /** * Append a new item to the bottom of the original file and add a generated header. * * @param src contents of the original file * @param newSrc new content to append into the original file * @param tag used to update and remove merges * @param comment comment style `//` or `#` */ function appendContents({ src, tag, comment, newSrc, }) { const generatedComment = (0, generateCode_1.createGeneratedComment)(newSrc, tag, comment); if (!src.includes(generatedComment.start)) { // Ensure the old generated contents are removed. const sanitizedTarget = (0, generateCode_1.removeGeneratedContents)(src, tag); const contentsToAdd = [ generatedComment.start, // @begin newSrc, // contents generatedComment.end, // @end ].join('\n'); return { contents: sanitizedTarget ?? src + contentsToAdd, didAppend: true, didClear: !!sanitizedTarget, }; } return { contents: src, didClear: false, didAppend: false }; }