Skip to content

Commit de420d9

Browse files
committed
abstracting out year regex
1 parent 4df2cf4 commit de420d9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/test-for-current-year.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ const fs = require("fs-extra")
33
const globby = require("globby")
44

55
const year = (new Date()).getFullYear()
6+
const yearRegex = new RegExp(`Copyright \\(c\\) ${year} GitHub Inc\\.`)
67

78
test(`LICENSE files have the current year ${year}`, t => {
89
return globby(["**/LICENSE", "!**/node_modules/**/LICENSE"])
910
.then(paths => {
1011
t.plan(paths.length)
1112
return paths.map(path => {
1213
const license = fs.readFileSync(path, "utf8")
13-
return t.regex(license, new RegExp(`Copyright \\(c\\) ${year} GitHub Inc\\.`), `The license "${path}" does not include the current year ${year}`)
14+
return t.regex(license, yearRegex, `The license "${path}" does not include the current year ${year}`)
1415
})
1516
})
1617
})
@@ -22,7 +23,7 @@ test(`Source header copyrights have the current year ${year}`, t => {
2223
return paths.map(path => {
2324
const source = fs.readFileSync(path, "utf8")
2425
if (source.match(/Copyright \(c\)/)) {
25-
return t.regex(source, new RegExp(`Copyright \\(c\\) ${year} GitHub Inc\\.`), `The source's header "${path}" does not include the current year ${year}`)
26+
return t.regex(source, yearRegex, `The source's header "${path}" does not include the current year ${year}`)
2627
} else {
2728
return t.true(true)
2829
}

0 commit comments

Comments
 (0)