1
1
mirror of https://github.com/primer/css.git synced 2024-12-23 06:01:54 +03:00

Adding a test to check for the current year in the license and source header

This commit is contained in:
Jon Rohan 2017-10-27 11:25:09 -07:00
parent 07b2ae0503
commit 4df2cf43f8
11 changed files with 42 additions and 10 deletions

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 GitHub Inc.
Copyright (c) 2017 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -2,7 +2,7 @@
* Primer-core
* http://primercss.io
*
* Released under MIT license. Copyright 2015 GitHub, Inc.
* Released under MIT license. Copyright (c) 2017 GitHub Inc.
*/
// Primer master file

View File

@ -2,7 +2,7 @@
* Primer
* http://primercss.io
*
* Released under MIT license. Copyright 2015 GitHub, Inc.
* Released under MIT license. Copyright (c) 2017 GitHub Inc.
*/
// Primer master file

View File

@ -2,7 +2,7 @@
* Primer-marketing
* http://primercss.io
*
* Released under MIT license. Copyright 2015 GitHub, Inc.
* Released under MIT license. Copyright (c) 2017 GitHub Inc.
*/
// Primer master file

View File

@ -2,7 +2,7 @@
* Primer-product
* http://primercss.io
*
* Released under MIT license. Copyright 2015 GitHub, Inc.
* Released under MIT license. Copyright (c) 2017 GitHub Inc.
*/
// Primer master file

View File

@ -16,7 +16,8 @@
"release": "script/release",
"bump": "lerna publish --exact --skip-npm --since \"v$(npm info primer-css version)\"",
"new-module": "script/new-module",
"test": "lerna run test"
"test": "npm run test-all-modules && lerna run test",
"test-all-modules": "ava --verbose tests/test-*.js"
},
"devDependencies": {
"@storybook/addon-options": "^3.2.6",

View File

@ -1,3 +1,3 @@
#!/bin/bash
set -e
$(dirname $0)/npm-run ava --verbose $(dirname $0)/../tests/modules/test-*.js
$(dirname $0)/npm-run ava --verbose $(dirname $0)/../tests/modules/test-document-styles.js

View File

@ -0,0 +1,31 @@
const test = require("ava")
const fs = require("fs-extra")
const globby = require("globby")
const year = (new Date()).getFullYear()
test(`LICENSE files have the current year ${year}`, t => {
return globby(["**/LICENSE", "!**/node_modules/**/LICENSE"])
.then(paths => {
t.plan(paths.length)
return paths.map(path => {
const license = fs.readFileSync(path, "utf8")
return t.regex(license, new RegExp(`Copyright \\(c\\) ${year} GitHub Inc\\.`), `The license "${path}" does not include the current year ${year}`)
})
})
})
test(`Source header copyrights have the current year ${year}`, t => {
return globby(["**/*.css", "**/*.scss", "!**/node_modules/**", "!**/build/**"])
.then(paths => {
t.plan(paths.length)
return paths.map(path => {
const source = fs.readFileSync(path, "utf8")
if (source.match(/Copyright \(c\)/)) {
return t.regex(source, new RegExp(`Copyright \\(c\\) ${year} GitHub Inc\\.`), `The source's header "${path}" does not include the current year ${year}`)
} else {
return t.true(true)
}
})
})
})

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 GitHub Inc.
Copyright (c) 2017 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 GitHub Inc.
Copyright (c) 2017 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 GitHub Inc.
Copyright (c) 2017 GitHub Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal