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

Pulled variable defaulting from appendPeriodIfMissing(). Updated inquires accordingly. Changed checking end of string with endsWith().

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

+ 1 - 1
dev/tasks/dev/utils/inquiries.js

@@ -71,7 +71,7 @@ module.exports = {
 				name: 'description',
 				message: 'Package description (one sentence, must end with period):'
 			} ], ( answers ) => {
-				resolve( sanitize.appendPeriodIfMissing( answers.description ) );
+				resolve( sanitize.appendPeriodIfMissing( answers.description || '' ) );
 			} );
 		} );
 	}

+ 2 - 2
dev/tasks/dev/utils/sanitize.js

@@ -7,10 +7,10 @@
 
 module.exports = {
 	appendPeriodIfMissing( text ) {
-		text = text ? text.trim() : '';
+		text = text.trim();
 		const length = text.length;
 
-		if ( length > 0 && text[ length - 1 ] !== '.' ) {
+		if ( length > 0 && !text.endsWith( '.' ) ) {
 			text += '.';
 		}