Podfile.prototype.__parseForDeclarations = function()

in lib/Podfile.js [68:103]


Podfile.prototype.__parseForDeclarations = function (text) {
    // split by \n
    const arr = text.split('\n');

    // getting lines between "platform :ios, '13.0'"" and "target 'HelloCordova'" do
    const declarationsPreRE = /platform :ios,\s+'[^']+'/;
    const declarationsPostRE = /target\s+'[^']+'\s+do/;
    const declarationRE = /^\s*[^#]/;

    return arr.reduce((acc, line) => {
        switch (acc.state) {
        case 0:
            if (declarationsPreRE.exec(line)) {
                acc.state = 1; // Start to read
            }
            break;
        case 1:
            if (declarationsPostRE.exec(line)) {
                acc.state = 2; // Finish to read
            } else {
                acc.lines.push(line);
            }
            break;
        case 2:
        default:
            // do nothing;
        }
        return acc;
    }, { state: 0, lines: [] })
        .lines
        .filter(line => declarationRE.exec(line))
        .reduce((obj, line) => {
            obj[line] = line;
            return obj;
        }, {});
};