Skip to content

Commit

Permalink
build: avoid dynamic date in build
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Jun 5, 2021
1 parent e77ae8f commit b272685
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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 Samuel Gratzl
Copyright (c) 2021 Samuel Gratzl

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
13 changes: 12 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ import fs from 'fs';

const pkg = JSON.parse(fs.readFileSync('./package.json'));

function resolveYear() {
// Extract copyrights from the LICENSE.
const license = fs.readFileSync("./LICENSE", "utf-8").toString();
const matches = Array.from(license.matchAll(/\(c\) (\d+)/gm));
if (!matches || matches.length === 0) {
return 2021;
}
return matches[matches.length - 1][1];
}
const year = resolveYear();

const banner = `/**
* ${pkg.name}
* ${pkg.homepage}
*
* Copyright (c) ${new Date().getFullYear()} ${pkg.author.name} <${pkg.author.email}>
* Copyright (c) ${year} ${pkg.author.name} <${pkg.author.email}>
*/
`;

Expand Down

0 comments on commit b272685

Please sign in to comment.