react-native-integrate
Version:
Automate integration of additional code into React Native projects
34 lines (33 loc) • 997 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.findInsertionPoint = findInsertionPoint;
const variables_1 = require("../variables");
function findInsertionPoint(content, textOrRegex) {
if (typeof textOrRegex == 'string') {
textOrRegex = (0, variables_1.getText)(textOrRegex);
const index = content.indexOf(textOrRegex);
if (index == -1)
return {
start: -1,
end: -1,
match: null,
};
return {
start: index,
end: index + textOrRegex.length,
match: textOrRegex,
};
}
const match = new RegExp((0, variables_1.getText)(textOrRegex.regex), textOrRegex.flags).exec(content);
if (!match)
return {
start: -1,
end: -1,
match: null,
};
return {
start: match.index,
end: match.index + match[0].length,
match: match[0],
};
}