File tree 2 files changed +24
-5
lines changed
2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const { resolve } = require('path');
19
19
const simpleGit = require ( 'simple-git/promise' ) ;
20
20
const fs = require ( 'mz/fs' ) ;
21
21
const ora = require ( 'ora' ) ;
22
+ const chalk = require ( 'chalk' ) ;
22
23
23
24
const root = resolve ( __dirname , '../..' ) ;
24
25
const git = simpleGit ( root ) ;
@@ -116,16 +117,24 @@ async function doLicenseCommit(changedFiles) {
116
117
117
118
const hasDiff = await git . diff ( ) ;
118
119
119
- if ( ! hasDiff ) return ;
120
+ if ( ! hasDiff ) {
121
+ console . log (
122
+ chalk `\n{red License pass caused no changes.} Skipping commit.\n`
123
+ ) ;
124
+ return ;
125
+ }
120
126
121
127
const gitSpinner = ora ( ' Creating automated license commit' ) . start ( ) ;
122
128
await git . add ( '.' ) ;
123
129
124
- await git . commit ( '[AUTOMATED]: License Headers' ) ;
130
+ const commit = await git . commit ( '[AUTOMATED]: License Headers' ) ;
125
131
126
132
gitSpinner . stopAndPersist ( {
127
133
symbol : '✅'
128
134
} ) ;
135
+ console . log (
136
+ chalk `{green Commited ${ commit . commit } to branch ${ commit . branch } }`
137
+ ) ;
129
138
}
130
139
131
140
module . exports = {
Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ async function doPrettierCommit(changedFiles) {
66
66
67
67
// Only run on .js or .ts files.
68
68
const targetFiles = changedFiles . filter ( line => line . match ( / ( j s | t s ) $ / ) ) ;
69
- if ( targetFiles . length === 0 ) return ;
69
+ if ( targetFiles . length === 0 ) {
70
+ console . log ( 'No files changed.' ) ;
71
+ }
70
72
71
73
const stylingSpinner = ora (
72
74
` Formatting ${ targetFiles . length } files with prettier`
@@ -88,15 +90,23 @@ async function doPrettierCommit(changedFiles) {
88
90
89
91
const hasDiff = await git . diff ( ) ;
90
92
91
- if ( ! hasDiff ) return ;
93
+ if ( ! hasDiff ) {
94
+ console . log (
95
+ chalk `\n{red Prettier formatting caused no changes.} Skipping commit.\n`
96
+ ) ;
97
+ return ;
98
+ }
92
99
93
100
const gitSpinner = ora ( ' Creating automated style commit' ) . start ( ) ;
94
101
await git . add ( targetFiles ) ;
95
102
96
- await git . commit ( '[AUTOMATED]: Prettier Code Styling' ) ;
103
+ const commit = await git . commit ( '[AUTOMATED]: Prettier Code Styling' ) ;
97
104
gitSpinner . stopAndPersist ( {
98
105
symbol : '✅'
99
106
} ) ;
107
+ console . log (
108
+ chalk `{green Commited ${ commit . commit } to branch ${ commit . branch } }`
109
+ ) ;
100
110
}
101
111
102
112
module . exports = {
You can’t perform that action at this time.
0 commit comments