Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 64c63d6

Browse files
author
Cdok
committed
reverted removal of --update flag
1 parent 8a4c8d5 commit 64c63d6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

copyright/copyright.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const currentYear = new Date().getFullYear()
2020
const langs = {}
2121

2222
let lintMode = true
23+
let updateMode = false
2324
let 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+
104111
buildSupportedExtensions()
105112

106113
args
@@ -112,7 +119,7 @@ args
112119
const ext = file.match(/\.[0-9a-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+
}

0 commit comments

Comments
 (0)