@embrace-io/react-native
Version:
A React Native wrapper for the Embrace SDK
26 lines (25 loc) • 698 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addAfter = exports.hasMatch = void 0;
const hasMatch = (lines, substring) => {
return lines.find(line => line.includes(substring));
};
exports.hasMatch = hasMatch;
const addAfter = (lines, matcher, toAdd) => {
let match;
let matchIndex = 0;
for (let l = 0; l < lines.length; l++) {
match = lines[l].match(matcher);
if (match) {
matchIndex = l;
break;
}
}
if (!match) {
return false;
}
const whitespace = match[1];
lines.splice(matchIndex + 1, 0, `${whitespace}${toAdd}`);
return true;
};
exports.addAfter = addAfter;