-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
// Copyright 2023 J.W. Lagendijk. All rights reserved. MIT license. | ||
|
||
export * from "./src/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2023 J.W. Lagendijk. All rights reserved. MIT license. | ||
|
||
import { globToRegExp, walk } from "../dev_deps.ts"; | ||
|
||
const EXTENSIONS = [".ts"]; | ||
const EXCLUDED_DIRS = ["cov"]; | ||
|
||
const ROOT = new URL("../", import.meta.url); | ||
const CHECK = Deno.args.includes("--check"); | ||
const CURRENT_YEAR = new Date().getFullYear(); | ||
const RX_COPYRIGHT = new RegExp( | ||
`// Copyright ([0-9]{4}) J.W. Lagendijk\\. All rights reserved\\. MIT license\\.\n`, | ||
); | ||
const COPYRIGHT = `// Copyright ${CURRENT_YEAR} J.W. Lagendijk. All rights reserved. MIT license.`; | ||
|
||
let failed = false; | ||
|
||
for await ( | ||
const { path } of walk(ROOT, { | ||
exts: EXTENSIONS, | ||
skip: [ | ||
...EXCLUDED_DIRS.map((path) => globToRegExp(path)), | ||
/node_modules/, | ||
/npm/, | ||
/script/, | ||
/_local_testing\.ts/, | ||
], | ||
includeDirs: false, | ||
}) | ||
) { | ||
const content = await Deno.readTextFile(path); | ||
const match = content.match(RX_COPYRIGHT); | ||
|
||
if (!match) { | ||
if (CHECK) { | ||
console.error(`Missing copyright header: ${path}`); | ||
failed = true; | ||
} else { | ||
const contentWithCopyright = COPYRIGHT + "\n" + content; | ||
await Deno.writeTextFile(path, contentWithCopyright); | ||
console.log("Copyright header automatically added to " + path); | ||
} | ||
} else if (parseInt(match[1]) !== CURRENT_YEAR) { | ||
if (CHECK) { | ||
console.error(`Incorrect copyright year: ${path}`); | ||
failed = true; | ||
} else { | ||
const index = match.index ?? 0; | ||
const contentWithoutCopyright = content.replace(match[0], ""); | ||
const contentWithCopyright = contentWithoutCopyright.substring(0, index) + | ||
COPYRIGHT + "\n" + contentWithoutCopyright.substring(index); | ||
await Deno.writeTextFile(path, contentWithCopyright); | ||
console.log("Copyright header automatically updated in " + path); | ||
} | ||
} | ||
} | ||
|
||
if (failed) { | ||
console.info(`Copyright header should be "${COPYRIGHT}"`); | ||
Deno.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Copyright 2023 J.W. Lagendijk. All rights reserved. MIT license. | ||
|
||
export * from "./deno/Pastebin.ts"; | ||
export * from "./lib/Scraper.ts"; | ||
export * from "./lib/interfaces.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Copyright 2023 J.W. Lagendijk. All rights reserved. MIT license. | ||
|
||
export * from "./Pastebin.ts"; | ||
export * from "../lib/Scraper.ts"; | ||
export * from "../lib/interfaces.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters