/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

const {set, cd, sed, rm} = require('shelljs');
const path = require('path');
const log = console.log;

log('===== about to run the postinstall-patches.js script     =====');
// fail on first error
set('-e');
// print commands as being executed
set('-v');
// jump to project root
cd(path.join(__dirname, '../'));

/* EXAMPLE PATCH:
// https://github.com/ReactiveX/rxjs/pull/3302
// make node_modules/rxjs compilable with Typescript 2.7
// remove when we update to rxjs v6
log('\n# patch: reactivex/rxjs#3302 make node_modules/rxjs compilable with Typescript 2.7');
sed('-i', '(\'response\' in xhr)', '(\'response\' in (xhr as any))',
    'node_modules/rxjs/src/observable/dom/AjaxObservable.ts');
*/
log('\n# patch: ReactiveX/rxjs#3534 make node_modules/rxjs compilable without rxjs-compat');
sed('-i', /\["\*\*\/\*\.ts"],/, '["internal/**/*.ts"],',
  'node_modules/rxjs/src/BUILD.bazel');
sed('-i', /glob\(\["\*\.ts"]\)/, 'glob(["index.ts"])',
   'node_modules/rxjs/src/operators/BUILD.bazel');

log('===== finished running the postinstall-patches.js script =====');

@@ -899,304 +899,8 @@
 ;%0A*/
-%0Alog('%5Cn# patch: ReactiveX/rxjs#3534 make node_modules/rxjs compilable without rxjs-compat');%0Ased('-i', /%5C%5B%22%5C*%5C*%5C/%5C*%5C.ts%22%5D,/, '%5B%22internal/**/*.ts%22%5D,',%0A  'node_modules/rxjs/src/BUILD.bazel');%0Ased('-i', /glob%5C(%5C%5B%22%5C*%5C.ts%22%5D%5C)/, 'glob(%5B%22index.ts%22%5D)',%0A   'node_modules/rxjs/src/operators/BUILD.bazel');
 %0A%0Alo

remove a postinstall-patch to fix rxjs (#23234)