Skip to content

Commit

Permalink
Merge pull request #384 from primer/year_test
Browse files Browse the repository at this point in the history
Adding a test to check for the current year in the license and source…
  • Loading branch information
jonrohan authored Oct 27, 2017
2 parents 07b2ae0 + de420d9 commit 87240f8
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/primer-core/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/primer-css/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/primer-marketing/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/primer-product/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion script/test-docs
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions tests/test-for-current-year.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const test = require("ava")
const fs = require("fs-extra")
const globby = require("globby")

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

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, yearRegex, `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, yearRegex, `The source's header "${path}" does not include the current year ${year}`)
} else {
return t.true(true)
}
})
})
})
2 changes: 1 addition & 1 deletion tools/generator-primer-module/app/templates/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/stylelint-config-primer/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/stylelint-selector-no-utility/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 87240f8

Please sign in to comment.