8
0
Просмотр исходного кода

Moved appendPeriodIfMissing to separate module.

Maksymilian Barnaś 9 лет назад
Родитель
Сommit
30cf61ee97
2 измененных файлов с 21 добавлено и 12 удалено
  1. 2 12
      dev/tasks/dev/utils/inquiries.js
  2. 19 0
      dev/tasks/dev/utils/sanitize.js

+ 2 - 12
dev/tasks/dev/utils/inquiries.js

@@ -6,6 +6,7 @@
 'use strict';
 
 const inquirer = require( 'inquirer' );
+const sanitize = require( './sanitize' );
 const DEFAULT_PLUGIN_NAME_PREFIX = 'ckeditor5-';
 const DEFAULT_PLUGIN_VERSION = '0.0.1';
 const DEFAULT_GITHUB_URL_PREFIX = 'ckeditor/';
@@ -70,19 +71,8 @@ module.exports = {
 				name: 'description',
 				message: 'Package description (one sentence, must end with period):'
 			} ], ( answers ) => {
-				resolve( appendPeriodIfMissing( answers.description ) );
+				resolve( sanitize.appendPeriodIfMissing( answers.description ) );
 			} );
 		} );
 	}
 };
-
-function appendPeriodIfMissing( text ) {
-	text = text ? text.trim() : '';
-	const length = text.length;
-
-	if ( length > 0 && text[ length - 1 ] !== '.' ) {
-		text += '.';
-	}
-
-	return text;
-}

+ 19 - 0
dev/tasks/dev/utils/sanitize.js

@@ -0,0 +1,19 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+module.exports = {
+	appendPeriodIfMissing( text ) {
+		text = text ? text.trim() : '';
+		const length = text.length;
+
+		if ( length > 0 && text[ length - 1 ] !== '.' ) {
+			text += '.';
+		}
+
+		return text;
+	}
+};