33var wrap = require ( 'word-wrap' ) ;
44var map = require ( 'lodash.map' ) ;
55var longest = require ( 'longest' ) ;
6- var chalk = require ( 'chalk' ) ;
7- var lerna = require ( './lerna.js' )
6+ var chalk = import ( 'chalk' ) . default ;
7+ var lerna = require ( './lerna.js' )
88
9- var filter = function ( array ) {
10- return array . filter ( function ( x ) {
9+ var filter = function ( array ) {
10+ return array . filter ( function ( x ) {
1111 return x ;
1212 } ) ;
1313} ;
1414
15- var headerLength = function ( answers ) {
15+ var headerLength = function ( answers ) {
1616 return (
1717 answers . type . length + 2 + ( answers . scope ? answers . scope . length + 2 : 0 )
1818 ) ;
1919} ;
2020
21- var maxSummaryLength = function ( options , answers ) {
21+ var maxSummaryLength = function ( options , answers ) {
2222 return options . maxHeaderWidth - headerLength ( answers ) ;
2323} ;
2424
25- var filterSubject = function ( subject , disableSubjectLowerCase ) {
25+ var filterSubject = function ( subject , disableSubjectLowerCase ) {
2626 subject = subject . trim ( ) ;
2727 if ( ! disableSubjectLowerCase && subject . charAt ( 0 ) . toLowerCase ( ) !== subject . charAt ( 0 ) ) {
2828 subject =
@@ -37,11 +37,11 @@ var filterSubject = function(subject, disableSubjectLowerCase) {
3737// This can be any kind of SystemJS compatible module.
3838// We use Commonjs here, but ES6 or AMD would do just
3939// fine.
40- module . exports = function ( options ) {
40+ module . exports = function ( options ) {
4141 var types = options . types ;
4242
4343 var length = longest ( Object . keys ( types ) ) . length + 1 ;
44- var choices = map ( types , function ( type , key ) {
44+ var choices = map ( types , function ( type , key ) {
4545 return {
4646 name : ( key + ':' ) . padEnd ( length ) + ' ' + type . description ,
4747 value : key
@@ -60,7 +60,7 @@ module.exports = function(options) {
6060 //
6161 // By default, we'll de-indent your commit
6262 // template and will keep empty lines.
63- prompter : function ( cz , commit ) {
63+ prompter : function ( cz , commit ) {
6464 // Let's ask some questions of the user
6565 // so that we can populate our commit
6666 // template.
@@ -82,7 +82,7 @@ module.exports = function(options) {
8282 message :
8383 'What is the scope of this change (e.g. component or file name): (press enter to skip)' ,
8484 default : options . defaultScope ,
85- filter : function ( value ) {
85+ filter : function ( value ) {
8686 return options . disableScopeLowerCase
8787 ? value . trim ( )
8888 : value . trim ( ) . toLowerCase ( ) ;
@@ -91,35 +91,35 @@ module.exports = function(options) {
9191 {
9292 type : 'input' ,
9393 name : 'subject' ,
94- message : function ( answers ) {
94+ message : function ( answers ) {
9595 return (
9696 'Write a short, imperative tense description of the change (max ' +
9797 maxSummaryLength ( options , answers ) +
9898 ' chars):\n'
9999 ) ;
100100 } ,
101101 default : options . defaultSubject ,
102- validate : function ( subject , answers ) {
102+ validate : function ( subject , answers ) {
103103 var filteredSubject = filterSubject ( subject , options . disableSubjectLowerCase ) ;
104104 return filteredSubject . length == 0
105105 ? 'subject is required'
106106 : filteredSubject . length <= maxSummaryLength ( options , answers )
107- ? true
108- : 'Subject length must be less than or equal to ' +
107+ ? true
108+ : 'Subject length must be less than or equal to ' +
109109 maxSummaryLength ( options , answers ) +
110110 ' characters. Current length is ' +
111111 filteredSubject . length +
112112 ' characters.' ;
113113 } ,
114- transformer : function ( subject , answers ) {
114+ transformer : function ( subject , answers ) {
115115 var filteredSubject = filterSubject ( subject , options . disableSubjectLowerCase ) ;
116116 var color =
117117 filteredSubject . length <= maxSummaryLength ( options , answers )
118118 ? chalk . green
119119 : chalk . red ;
120120 return color ( '(' + filteredSubject . length + ') ' + subject ) ;
121121 } ,
122- filter : function ( subject ) {
122+ filter : function ( subject ) {
123123 return filterSubject ( subject , options . disableSubjectLowerCase ) ;
124124 }
125125 } ,
@@ -142,10 +142,10 @@ module.exports = function(options) {
142142 default : '-' ,
143143 message :
144144 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself:\n' ,
145- when : function ( answers ) {
145+ when : function ( answers ) {
146146 return answers . isBreaking && ! answers . body ;
147147 } ,
148- validate : function ( breakingBody , answers ) {
148+ validate : function ( breakingBody , answers ) {
149149 return (
150150 breakingBody . trim ( ) . length > 0 ||
151151 'Body is required for BREAKING CHANGE'
@@ -156,7 +156,7 @@ module.exports = function(options) {
156156 type : 'input' ,
157157 name : 'breaking' ,
158158 message : 'Describe the breaking changes:\n' ,
159- when : function ( answers ) {
159+ when : function ( answers ) {
160160 return answers . isBreaking ;
161161 }
162162 } ,
@@ -173,7 +173,7 @@ module.exports = function(options) {
173173 default : '-' ,
174174 message :
175175 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself:\n' ,
176- when : function ( answers ) {
176+ when : function ( answers ) {
177177 return (
178178 answers . isIssueAffected && ! answers . body && ! answers . breakingBody
179179 ) ;
@@ -183,13 +183,13 @@ module.exports = function(options) {
183183 type : 'input' ,
184184 name : 'issues' ,
185185 message : 'Add issue references (e.g. "fix #123", "re #123".):\n' ,
186- when : function ( answers ) {
186+ when : function ( answers ) {
187187 return answers . isIssueAffected ;
188188 } ,
189189 default : options . defaultIssues ? options . defaultIssues : undefined
190190 } ,
191191 lerna . genQuesion ( ) ,
192- ] ) . then ( function ( answers ) {
192+ ] ) . then ( function ( answers ) {
193193 var wrapOptions = {
194194 trim : true ,
195195 cut : false ,
0 commit comments