瀏覽代碼

Added loading tasks

Maksymilian Barnaś 9 年之前
父節點
當前提交
c3d69d310c
共有 3 個文件被更改,包括 24 次插入13 次删除
  1. 3 1
      dev/tasks/exec/functions/bump-year.js
  2. 18 7
      dev/tasks/exec/tasks.js
  3. 3 5
      dev/tasks/exec/tasks/exec.js

+ 3 - 1
dev/tasks/exec/functions/bump-year.js

@@ -9,4 +9,6 @@
  * {String} packagePath
  * {Minimatch} params
  */
-module.exports = () => {};
+module.exports = () => {
+	return 'bump-year!';
+};

+ 18 - 7
dev/tasks/exec/tasks.js

@@ -25,16 +25,27 @@ module.exports = ( config ) => {
 
 	const tasks = {
 		execOnRepositories() {
-			const options = minimist( process.argv.slice( 2 ), {
+			// Omit `gulp exec` part of arguments
+			const options = minimist( process.argv.slice( 3 ), {
 				boolean: [ 'dry-run' ],
+				alias: { t: 'task' },
 				default: {
-					'dry-run': true
-				}
+					'dry-run': false
+				},
+				stopEarly: false
 			} );
-
-			const installTask = () => {};
-
-			return exec( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'dry-run' ] );
+			let execTask;
+
+			try {
+				execTask = require( `./functions/${ options.task }` );
+			}
+			catch ( error ) {
+				log.err( `Cannot find task ${ options.task }` );
+			}
+
+			if ( execTask ) {
+				exec( execTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'dry-run' ] );
+			}
 		},
 
 		register() {

+ 3 - 5
dev/tasks/exec/tasks/exec.js

@@ -11,13 +11,13 @@ const path = require( 'path' );
 const log = require( '../utils/log' );
 
 /**
- * @param {Function} installTask Install task to use on each dependency that is missing from workspace.
+ * @param {Function} execTask Task to use on each dependency.
  * @param {String} ckeditor5Path Path to main CKEditor5 repository.
  * @param {Object} packageJSON Parsed package.json file from CKEditor5 repository.
  * @param {String} workspaceRoot Relative path to workspace root.
  * @param {Boolean} dryRun
  */
-module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot, dryRun ) => {
+module.exports = ( execTask, ckeditor5Path, packageJSON, workspaceRoot, dryRun ) => {
 	const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
 
 	// Get all CKEditor dependencies from package.json.
@@ -39,13 +39,11 @@ module.exports = ( installTask, ckeditor5Path, packageJSON, workspaceRoot, dryRu
 					} else {
 						try {
 							log.out( `Executing task on ${ repositoryURL }...` );
+							log.out( execTask() );
 						} catch ( error ) {
 							log.err( error );
 						}
 					}
-				} else {
-					// Directory does not exits in workspace - install it.
-					// installTask( ckeditor5Path, workspaceRoot, repositoryURL );
 				}
 			}
 		} else {