8
0

tasks.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* jshint node: true, esnext: true */
  2. 'use strict';
  3. const gulp = require( 'gulp' );
  4. const minimist = require( 'minimist' );
  5. const statusTask = require( './tasks/status' );
  6. const initTask = require( './tasks/init' );
  7. const installTask = require( './tasks/install' );
  8. const pluginCreateTask = require( './tasks/create-package' );
  9. const updateTask = require( './tasks/update' );
  10. const relinkTask = require( './tasks/relink' );
  11. module.exports = ( config ) => {
  12. const ckeditor5Path = process.cwd();
  13. const packageJSON = require( '../../../package.json' );
  14. gulp.task( 'init', () => {
  15. initTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log );
  16. } );
  17. gulp.task( 'create-package', ( done ) => {
  18. pluginCreateTask( ckeditor5Path, config.WORKSPACE_DIR, console.log )
  19. .then( done )
  20. .catch( ( error ) => done( error ) );
  21. } );
  22. gulp.task( 'update', () => {
  23. const options = minimist( process.argv.slice( 2 ), {
  24. boolean: [ 'npm-update' ],
  25. default: {
  26. 'npm-update': false
  27. }
  28. } );
  29. updateTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, options[ 'npm-update' ] );
  30. } );
  31. gulp.task( 'status', () => {
  32. statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
  33. } );
  34. gulp.task( 'relink', () => {
  35. relinkTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR, console.log, console.error );
  36. } );
  37. gulp.task( 'install', () => {
  38. const options = minimist( process.argv.slice( 2 ), {
  39. string: [ 'package' ],
  40. default: {
  41. plugin: ''
  42. }
  43. } );
  44. if ( options.package ) {
  45. installTask( ckeditor5Path, config.WORKSPACE_DIR, options.package, console.log );
  46. } else {
  47. throw new Error( 'Please provide a package to install: gulp dev-install --plugin <path|GitHub URL|name>' );
  48. }
  49. } );
  50. };