This repository was archived by the owner on Aug 8, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ const currentYear = new Date().getFullYear()
2020const langs = { }
2121
2222let lintMode = true
23+ let updateMode = false
2324let error = false
2425
2526// we don't want to pass node and copyright.js directories to the glob
@@ -88,6 +89,7 @@ if (args.length === 0 || args.indexOf('--help') >= 0) {
8889 Options:
8990
9091 --fix run in fix mode
92+ --update update the year in existing headers
9193
9294 Visit ${ cyan } https://github.com/mobify/mobify-code-style${ defaultFG } to learn more.
9395` )
@@ -101,6 +103,11 @@ if (args.indexOf('--fix') >= 0) {
101103 lintMode = false
102104}
103105
106+ if ( args . indexOf ( '--update' ) >= 0 ) {
107+ args . splice ( args . indexOf ( '--update' ) , 1 )
108+ updateMode = true
109+ }
110+
104111buildSupportedExtensions ( )
105112
106113args
112119 const ext = file . match ( / \. [ 0 - 9 a - z ] + $ / i) [ 0 ]
113120 let newData = ''
114121
115- if ( hasCopyrightHeader && ! lintMode ) {
122+ if ( hasCopyrightHeader && updateMode ) {
116123 let previousHeaderYear = content . toString ( ) . match ( / (?: \( c \) ) (?: \s ) ( \d { 4 } ) / ) [ 1 ]
117124 if ( previousHeaderYear !== currentYear . toString ( ) ) {
118125 newData = content . toString ( ) . replace ( `(c) ${ previousHeaderYear } ` , `(c) ${ currentYear } ` )
@@ -149,4 +156,4 @@ if (error) {
149156 process . exit ( 1 )
150157} else {
151158 console . log ( `${ cyan } Copyright headers are present in target files` )
152- }
159+ }
You can’t perform that action at this time.
0 commit comments