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

Forcing period at the end of package description.

Maksymilian Barnaś 9 лет назад
Родитель
Сommit
032a5ebeb4
1 измененных файлов с 13 добавлено и 2 удалено
  1. 13 2
      dev/tasks/dev/utils/inquiries.js

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

@@ -68,10 +68,21 @@ module.exports = {
 		return new Promise( ( resolve ) => {
 			inquirer.prompt( [ {
 				name: 'description',
-				message: 'Package description (one sentence):'
+				message: 'Package description (one sentence, must end with period):'
 			} ], ( answers ) => {
-				resolve( answers.description || '' );
+				resolve( appendPeriodIfMissing( answers.description ) );
 			} );
 		} );
 	}
 };
+
+function appendPeriodIfMissing( text ) {
+	text = text ? String.prototype.trim.call( text ) : '';
+	const length = text.length;
+
+	if ( length > 0 && text[length - 1] !== '.' ) {
+		text += '.';
+	}
+
+	return text;
+}