remove-dependency.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env node
  2. /* -----------------------------------------------------------------------------
  3. | Copyright (c) Jupyter Development Team.
  4. | Distributed under the terms of the Modified BSD License.
  5. |----------------------------------------------------------------------------*/
  6. import * as path from 'path';
  7. import * as utils from './utils';
  8. // Make sure we have required command line arguments.
  9. if (process.argv.length !== 3) {
  10. const msg = '** Must supply a library name\n';
  11. process.stderr.write(msg);
  12. process.exit(1);
  13. }
  14. const name = process.argv[2];
  15. // Handle the packages
  16. utils.getLernaPaths().forEach(pkgPath => {
  17. handlePackage(pkgPath);
  18. });
  19. handlePackage(path.resolve('.'));
  20. /**
  21. * Handle an individual package on the path - update the dependency.
  22. */
  23. function handlePackage(packagePath: string): void {
  24. // Read in the package.json.
  25. packagePath = path.join(packagePath, 'package.json');
  26. let data: any;
  27. try {
  28. data = utils.readJSONFile(packagePath);
  29. } catch (e) {
  30. console.debug('Skipping package ' + packagePath);
  31. return;
  32. }
  33. // Update dependencies as appropriate.
  34. for (const dtype of ['dependencies', 'devDependencies']) {
  35. const deps = data[dtype] || {};
  36. delete deps[name];
  37. }
  38. // Write the file back to disk.
  39. utils.writePackageData(packagePath, data);
  40. }
  41. // Update the core jupyterlab build dependencies.
  42. utils.run('jlpm run integrity');