Преглед изворни кода

Merge pull request #196 from ckeditor/t/186

Additional aliases for Gulp.
Piotrek Koszuliński пре 9 година
родитељ
комит
4ae55640a2
3 измењених фајлова са 60 додато и 12 уклоњено
  1. 20 12
      dev/tasks/dev/tasks.js
  2. 20 0
      dev/tests/dev/status.js
  3. 20 0
      dev/tests/dev/update.js

+ 20 - 12
dev/tasks/dev/tasks.js

@@ -36,20 +36,13 @@ module.exports = ( config ) => {
 			.catch( ( error )  => done( error ) );
 	} );
 
-	gulp.task( 'update', () => {
-		const options = minimist( process.argv.slice( 2 ), {
-			boolean: [ 'npm-update' ],
-			default: {
-				'npm-update': false
-			}
-		} );
+	gulp.task( 'update', updateTaskHandler );
 
-		updateTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'npm-update' ] );
-	} );
+	gulp.task( 'pull', updateTaskHandler );
 
-	gulp.task( 'status', () => {
-		statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
-	} );
+	gulp.task( 'status', statusTaskHandler );
+
+	gulp.task( 'st', statusTaskHandler );
 
 	gulp.task( 'relink', () => {
 		relinkTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
@@ -69,4 +62,19 @@ module.exports = ( config ) => {
 			throw new Error( 'Please provide a package to install: gulp dev-install --plugin <path|GitHub URL|name>' );
 		}
 	} );
+
+	function updateTaskHandler() {
+		const options = minimist( process.argv.slice( 2 ), {
+			boolean: [ 'npm-update' ],
+			default: {
+				'npm-update': false
+			}
+		} );
+
+		return updateTask( installTask, ckeditor5Path, packageJSON, config.WORKSPACE_DIR, options[ 'npm-update' ] );
+	}
+
+	function statusTaskHandler() {
+		return statusTask( ckeditor5Path, packageJSON, config.WORKSPACE_DIR );
+	}
 };

+ 20 - 0
dev/tests/dev/status.js

@@ -7,10 +7,14 @@
 
 'use strict';
 
+require( '../../tasks/dev/tasks' )( {} );
 const sinon = require( 'sinon' );
 const tools = require( '../../tasks/dev/utils/tools' );
 const git = require( '../../tasks/dev/utils/git' );
 const path = require( 'path' );
+const chai = require( 'chai' );
+const expect = chai.expect;
+const gulp = require( 'gulp' );
 
 describe( 'dev-status', () => {
 	const statusTask = require( '../../tasks/dev/tasks/status' );
@@ -109,3 +113,19 @@ describe( 'dev-status', () => {
 		sinon.assert.calledWithExactly( writeErrorSpy, error );
 	} );
 } );
+
+describe( 'gulp task status', () => {
+	const tasks = gulp.tasks;
+
+	it( 'should be available', () => {
+		expect( tasks ).to.have.property( 'status' );
+		expect( tasks.status.fn ).to.be.a( 'function' );
+	} );
+
+	it( 'should have an alias', () => {
+		expect( tasks ).to.have.property( 'st' );
+		expect( tasks.st.fn ).to.be.a( 'function' );
+
+		expect( tasks.st.fn ).to.equal( tasks.status.fn );
+	} );
+} );

+ 20 - 0
dev/tests/dev/update.js

@@ -7,10 +7,14 @@
 
 'use strict';
 
+require( '../../tasks/dev/tasks' )( {} );
 const sinon = require( 'sinon' );
 const tools = require( '../../tasks/dev/utils/tools' );
 const git = require( '../../tasks/dev/utils/git' );
 const path = require( 'path' );
+const chai = require( 'chai' );
+const expect = chai.expect;
+const gulp = require( 'gulp' );
 
 describe( 'dev-update', () => {
 	const updateTask = require( '../../tasks/dev/tasks/update' );
@@ -236,3 +240,19 @@ describe( 'dev-update', () => {
 		sinon.assert.notCalled( spies.removeSymlink );
 	} );
 } );
+
+describe( 'gulp task update', () => {
+	const tasks = gulp.tasks;
+
+	it( 'should be available', () => {
+		expect( tasks ).to.have.property( 'update' );
+		expect( tasks.update.fn ).to.be.a( 'function' );
+	} );
+
+	it( 'should have an alias', () => {
+		expect( tasks ).to.have.property( 'pull' );
+		expect( tasks.pull.fn ).to.be.a( 'function' );
+
+		expect( tasks.pull.fn ).to.equal( tasks.update.fn );
+	} );
+} );