@@ -18,40 +18,38 @@ const log = execSync(`git log --reverse --pretty='format:%h %H%d %s (%aN)%n%b%n-
18
18
main ( )
19
19
20
20
function shortname ( url ) {
21
- let matched = url . match ( / h t t p s : \/ \/ g i t h u b \. c o m \/ ( [ ^ / ] + \/ [ ^ / ] + ) \/ (?: p u l l | i s s u e s ) \/ ( \d + ) / ) ||
21
+ const matched = url . match ( / h t t p s : \/ \/ g i t h u b \. c o m \/ ( [ ^ / ] + \/ [ ^ / ] + ) \/ (?: p u l l | i s s u e s ) \/ ( \d + ) / ) ||
22
22
url . match ( / h t t p s : \/ \/ ( n p m \. c o m m u n i t y ) \/ t \/ (?: [ ^ / ] + \/ ) ( \d + ) / )
23
- if ( ! matched ) return false
24
- let repo = matched [ 1 ]
25
- let id = matched [ 2 ]
26
- if ( repo !== 'npm/cli' ) {
23
+ if ( ! matched )
24
+ return false
25
+ const repo = matched [ 1 ]
26
+ const id = matched [ 2 ]
27
+ if ( repo !== 'npm/cli' )
27
28
return `${ repo } #${ id } `
28
- } else {
29
+ else
29
30
return `#${ id } `
30
- }
31
31
}
32
32
33
33
function printCommit ( c ) {
34
34
console . log ( `* [\`${ c . shortid } \`](https://github.com/npm/cli/commit/${ c . fullid } )` )
35
35
if ( c . fixes . length ) {
36
36
for ( const fix of c . fixes ) {
37
- let label = shortname ( fix )
38
- if ( label ) {
37
+ const label = shortname ( fix )
38
+ if ( label )
39
39
console . log ( ` [${ label } ](${ fix } )` )
40
- }
41
40
}
42
41
} else if ( c . prurl ) {
43
- let label = shortname ( c . prurl )
44
- if ( label ) {
42
+ const label = shortname ( c . prurl )
43
+ if ( label )
45
44
console . log ( ` [${ label } ](${ c . prurl } )` )
46
- } else {
45
+ else
47
46
console . log ( ` [#](${ c . prurl } )` )
48
- }
49
47
}
50
- let msg = c . message
48
+ const msg = c . message
51
49
. replace ( / ^ \s + / mg, '' )
52
50
. replace ( / ^ [ - a - z ] + : / , '' )
53
51
. replace ( / ^ / mg, ' ' )
54
- . replace ( / ^ R e v i e w e d - b y : @ .* / mg, '' )
52
+ . replace ( / ^ { 2 } R e v i e w e d - b y : @ .* / mg, '' )
55
53
. replace ( / \n $ / , '' )
56
54
// backtickify package@version
57
55
. replace ( / ^ ( \s * @ ? [ ^ @ \s ] + @ \d + [ . ] \d + [ . ] \d + ) \b ( \s * \S ) / g, '$1:$2' )
@@ -60,14 +58,13 @@ function printCommit (c) {
60
58
. replace ( / \b ( [ a - f 0 - 9 ] { 7 , 8 } ) \b / g, '[`$1`](https://github.com/npm/cli/commit/$1)' )
61
59
console . log ( msg )
62
60
// don't assign credit for dep updates
63
- if ( ! / ^ ` [ ^ ` ] + @ \d + \. \d + \. \d + [ ^ ` ] * ` : ? $ / m. test ( msg ) ) {
61
+ if ( ! / ^ { 2 } ` [ ^ ` ] + @ \d + \. \d + \. \d + [ ^ ` ] * ` : ? $ / m. test ( msg ) ) {
64
62
if ( c . credit ) {
65
63
c . credit . forEach ( function ( credit ) {
66
64
console . log ( ` ([@${ credit } ](https://github.com/${ credit } ))` )
67
65
} )
68
- } else {
66
+ } else
69
67
console . log ( ` ([@${ c . author } ](https://github.com/${ c . author } ))` )
70
- }
71
68
}
72
69
}
73
70
@@ -77,9 +74,9 @@ function main () {
77
74
line = line . replace ( / \r / g, '' )
78
75
let m
79
76
/* eslint no-cond-assign:0 */
80
- if ( / ^ - - - $ / . test ( line ) ) {
77
+ if ( / ^ - - - $ / . test ( line ) )
81
78
printCommit ( commit )
82
- } else if ( m = line . match ( / ^ ( [ a - f 0 - 9 ] { 7 , 10 } ) ( [ a - f 0 - 9 ] + ) (?: [ ( ] ( [ ^ ) ] + ) [ ) ] ) ? ( .* ?) [ ( ] ( .* ?) [ ) ] / ) ) {
79
+ else if ( m = line . match ( / ^ ( [ a - f 0 - 9 ] { 7 , 10 } ) ( [ a - f 0 - 9 ] + ) (?: [ ( ] ( [ ^ ) ] + ) [ ) ] ) ? ( .* ?) [ ( ] ( .* ?) [ ) ] / ) ) {
83
80
commit = {
84
81
shortid : m [ 1 ] ,
85
82
fullid : m [ 2 ] ,
@@ -88,23 +85,23 @@ function main () {
88
85
author : m [ 5 ] ,
89
86
prurl : null ,
90
87
fixes : [ ] ,
91
- credit : null
88
+ credit : null ,
92
89
}
93
- } else if ( m = line . match ( / ^ P R - U R L : ( .* ) / ) ) {
90
+ } else if ( m = line . match ( / ^ P R - U R L : ( .* ) / ) )
94
91
commit . prurl = m [ 1 ]
95
- } else if ( m = line . match ( / ^ C r e d i t : @ ( .* ) / ) ) {
96
- if ( ! commit . credit ) commit . credit = [ ]
92
+ else if ( m = line . match ( / ^ C r e d i t : @ ( .* ) / ) ) {
93
+ if ( ! commit . credit )
94
+ commit . credit = [ ]
97
95
commit . credit . push ( m [ 1 ] )
98
- } else if ( m = line . match ( / ^ (?: F i x (?: e s ) | C l o s e s ? ) : # ? ( [ 0 - 9 ] + ) / ) ) {
96
+ } else if ( m = line . match ( / ^ (?: F i x (?: e s ) | C l o s e s ? ) : # ? ( [ 0 - 9 ] + ) / ) )
99
97
commit . fixes . push ( `https://github.com/npm/cli/issues/${ m [ 1 ] } ` )
100
- } else if ( m = line . match ( / ^ (?: F i x (?: e s ) | C l o s e s ? ) : ( [ ^ # ] + ) # ( [ 0 - 9 ] * ) / ) ) {
98
+ else if ( m = line . match ( / ^ (?: F i x (?: e s ) | C l o s e s ? ) : ( [ ^ # ] + ) # ( [ 0 - 9 ] * ) / ) )
101
99
commit . fixes . push ( `https://github.com/${ m [ 1 ] } /issues/${ m [ 2 ] } ` )
102
- } else if ( m = line . match ( / ^ (?: F i x (?: e s ) | C l o s e s ? ) : ( h t t p s ? : \/ \/ .* ) / ) ) {
100
+ else if ( m = line . match ( / ^ (?: F i x (?: e s ) | C l o s e s ? ) : ( h t t p s ? : \/ \/ .* ) / ) )
103
101
commit . fixes . push ( m [ 1 ] )
104
- } else if ( m = line . match ( / ^ R e v i e w e d - B y : @ ( .* ) / ) ) {
102
+ else if ( m = line . match ( / ^ R e v i e w e d - B y : @ ( .* ) / ) )
105
103
commit . reviewed = m [ 1 ]
106
- } else if ( / \S / . test ( line ) ) {
104
+ else if ( / \S / . test ( line ) )
107
105
commit . message += `\n${ line } `
108
- }
109
106
} )
110
107
}
0 commit comments