remove-package.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*-----------------------------------------------------------------------------
  2. | Copyright (c) Jupyter Development Team.
  3. | Distributed under the terms of the Modified BSD License.
  4. |----------------------------------------------------------------------------*/
  5. /**
  6. * Remove an extension from the relevant metadata
  7. * files of the JupyterLab source tree so that it
  8. * is not included in the build. Intended for testing
  9. * adding/removing extensions against development
  10. * branches of JupyterLab.
  11. */
  12. import * as fs from 'fs-extra';
  13. import * as path from 'path';
  14. import * as utils from './utils';
  15. // Make sure we have required command line arguments.
  16. if (process.argv.length < 3) {
  17. let msg = '** Must supply a target extension name';
  18. process.stderr.write(msg);
  19. process.exit(1);
  20. }
  21. // Get the package name or path.
  22. let target = process.argv[2];
  23. let basePath = path.resolve('.');
  24. // Get the package.json of the extension.
  25. let packagePath = path.join(basePath, 'packages', target, 'package.json');
  26. if (!fs.existsSync(packagePath)) {
  27. packagePath = require.resolve(path.join(target, 'package.json'));
  28. }
  29. // Remove the package from the local tree.
  30. fs.removeSync(path.dirname(packagePath));
  31. // Update the core jupyterlab build dependencies.
  32. utils.run('npm run integrity');