update-mgit-branches.js 966 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env node
  2. /**
  3. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  4. * For licensing, see LICENSE.md.
  5. */
  6. /* eslint-env node */
  7. 'use strict';
  8. const branchName = process.argv[ 2 ];
  9. if ( !branchName ) {
  10. throw new Error( 'Missing branch name.' );
  11. }
  12. const path = require( 'path' );
  13. const { tools, logger } = require( '@ckeditor/ckeditor5-dev-utils' );
  14. const log = logger();
  15. const mgitJsonPath = path.resolve( __dirname, '..', '..', 'mgit.json' );
  16. log.info( 'Updating the "mgit.json"...' );
  17. tools.updateJSONFile( mgitJsonPath, mgitJson => {
  18. const dependencies = mgitJson.dependencies;
  19. for ( const packageName of Object.keys( dependencies ) ) {
  20. dependencies[ packageName ] = dependencies[ packageName ].split( '#' )[ 0 ];
  21. if ( branchName !== 'master' ) {
  22. dependencies[ packageName ] += '#' + branchName;
  23. }
  24. }
  25. return mgitJson;
  26. } );
  27. log.info( `Done. "mgit.json" uses the "${ branchName }" branch now.` );