index.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var schematics_1 = require("@angular-devkit/schematics");
  4. var tasks_1 = require("@angular-devkit/schematics/tasks");
  5. var rxjsCompatVersion = '^6.0.0-rc.0';
  6. function rxjsV6MigrationSchematic(_options) {
  7. return function (tree, context) {
  8. var pkgPath = '/package.json';
  9. var buffer = tree.read(pkgPath);
  10. if (buffer == null) {
  11. throw new schematics_1.SchematicsException('Could not read package.json');
  12. }
  13. var content = buffer.toString();
  14. var pkg = JSON.parse(content);
  15. if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
  16. throw new schematics_1.SchematicsException('Error reading package.json');
  17. }
  18. if (!pkg.dependencies) {
  19. pkg.dependencies = {};
  20. }
  21. pkg.dependencies['rxjs-compat'] = rxjsCompatVersion;
  22. tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
  23. context.addTask(new tasks_1.NodePackageInstallTask());
  24. return tree;
  25. };
  26. }
  27. exports.rxjsV6MigrationSchematic = rxjsV6MigrationSchematic;
  28. //# sourceMappingURL=index.js.map