Skip to content

Commit

Permalink
license year fun
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Sakharov committed Jun 3, 2023
1 parent af0f169 commit 20e8fbd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Check license
run: node tools/check_license.cjs

- name: Install dependencies
run: npm ci

Expand Down
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

node tools/check_license.cjs
npm run audit
npm run test_coverage
node tools/check_coverage.cjs
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Andrey Sakharov
Copyright (c) 2020-2023 Andrey Sakharov

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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ app.use((err, req, res, next) => {
res.status(500).send('Something broke!');
});

app.listen(2022, () => console.log('check it on http://localhost:2022?name=one'));
app.listen(2023, () => console.log('check it on http://localhost:2023?name=one'));
```
17 changes: 17 additions & 0 deletions tools/check_license.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('node:fs');
const { EOL } = require('node:os');
const path = require('node:path');

const LICENSE_PATH = path.join(process.cwd(), 'LICENSE');

const licenceContent = fs.readFileSync(LICENSE_PATH).toString();

const lines = licenceContent.split(EOL);

const copyrightLine = lines.find((l) => l.includes('Copyright (c)'));

const currentYear = new Date().getUTCFullYear().toString();

if (!copyrightLine.includes(currentYear)) {
throw new Error('update your licence first');
}

0 comments on commit 20e8fbd

Please sign in to comment.