|
|
@@ -13,20 +13,30 @@ const log = require( '../../utils/log' );
|
|
|
const tools = require( '../../utils/tools' );
|
|
|
const git = require( '../../utils/git' );
|
|
|
|
|
|
-module.exports = ( config ) => {
|
|
|
+/**
|
|
|
+ * Run task over ckeditor5 repositories.
|
|
|
+ * Example:
|
|
|
+ * gulp exec --task task-name
|
|
|
+ * Example of running task just for one repository:
|
|
|
+ * gulp exec --task task-name --one-repo
|
|
|
+ *
|
|
|
+ * @param {Object} config Task runner configuration.
|
|
|
+ * @returns {Stream} Stream with processed files.
|
|
|
+ */
|
|
|
+module.exports = function tasks( config ) {
|
|
|
const ckeditor5Path = process.cwd();
|
|
|
const packageJSON = require( '../../../package.json' );
|
|
|
const tasks = {
|
|
|
execOnRepositories() {
|
|
|
// Omit `gulp exec` part of arguments
|
|
|
- const options = minimist( process.argv.slice( 3 ), {
|
|
|
+ const parameters = minimist( process.argv.slice( 3 ), {
|
|
|
stopEarly: false,
|
|
|
} );
|
|
|
- let execTask;
|
|
|
+ let task;
|
|
|
|
|
|
try {
|
|
|
- if ( options.task ) {
|
|
|
- execTask = require( `./functions/${ options.task }` );
|
|
|
+ if ( parameters.task ) {
|
|
|
+ task = require( `./functions/${ parameters.task }` );
|
|
|
} else {
|
|
|
throw new Error( 'Missing task parameter: --task task-name' );
|
|
|
}
|
|
|
@@ -34,8 +44,8 @@ module.exports = ( config ) => {
|
|
|
log.err( error );
|
|
|
}
|
|
|
|
|
|
- if ( execTask ) {
|
|
|
- return exec( execTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options );
|
|
|
+ if ( task ) {
|
|
|
+ return execute( task, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, parameters );
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -52,11 +62,11 @@ module.exports = ( config ) => {
|
|
|
* @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 {Object} params Parameters provided to the task via command-line.
|
|
|
+ * @param {Object} parameters Parameters provided to the task via command-line.
|
|
|
*/
|
|
|
-function exec( execTask, ckeditor5Path, packageJSON, workspaceRoot, params ) {
|
|
|
+function execute( execTask, ckeditor5Path, packageJSON, workspaceRoot, parameters ) {
|
|
|
const workspaceAbsolutePath = path.join( ckeditor5Path, workspaceRoot );
|
|
|
-
|
|
|
+ const oneRepository = parameters[ 'one-repo' ];
|
|
|
// Get all CKEditor dependencies from package.json.
|
|
|
const dependencies = tools.getCKEditorDependencies( packageJSON.dependencies );
|
|
|
const mergedStream = merge();
|
|
|
@@ -75,11 +85,15 @@ function exec( execTask, ckeditor5Path, packageJSON, workspaceRoot, params ) {
|
|
|
try {
|
|
|
log.out( `Executing task on ${ repositoryURL }...` );
|
|
|
|
|
|
- mergedStream.add( execTask( repositoryAbsolutePath, params ) );
|
|
|
+ mergedStream.add( execTask( repositoryAbsolutePath, parameters ) );
|
|
|
} catch ( error ) {
|
|
|
log.err( error );
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ( oneRepository ) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
log.out( 'No CKEditor5 plugins in development mode.' );
|