build/index.js
function replaceBlocks(file, blocks) {
  blocks.forEach(block => {
    const index = file.search(block[0]);
    if (index > -1) {
      // Don't comment out blocks that have already been processed
      if (file.substring(index - 3, index) !== "/* ") {
        file = file.replace(block[0], "/* $1 */\n" + block[1]);
      }
    } else {
      maybeCompatible = false;
      console.log(`*** Error: RegExp ${block[0].toString()} did not match anything`);
    }
  });
  return file;
}
function replaceBlocks(file, blocks) {
  blocks.forEach(block => {
    const index = file.search(block[0]);
    if (index > -1) {
      // Don't comment out blocks that have already been processed
      if (file.substring(index - 3, index) !== "/* ") {
        file = file.replace(block[0], "/* $1 */\n" + block[1]);
      }
    } else {
      maybeCompatible = false;
      console.log(`*** Error: RegExp ${block[0].toString()} did not match anything`);
    }
  });
  return file;
}
function replaceBlocks ( file , blocks ) { blocks . forEach ( block => { const index = file . search ( block [ 0 ] ) ; if ( index > - 1 ) { // Don't comment out blocks that have already been processed if ( file . substring ( index - 3 , index ) !== "/* " ) { file = file . replace ( block [ 0 ] , "/* $1 */\n" + block [ 1 ] ) ; } } else { maybeCompatible = false ; console . log ( ` ${ block [ 0 ] . toString ( ) } ` ) ; } } ) ; return file ; }
Non-destructive replacement. The block is commented out by adding an opening /* and closing */. It does not account for internal block comments!
Non - destructive replacement . The block is commented out by adding an opening / * and closing * / . It does not account for internal block comments!