snippeteer/lib/snippets/copyright/copyright_generator.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-04-16 07:45:48 +02:00
/*
* Copyright (C) SapphireCode - All Rights Reserved
* This file is part of Snippeteer which is released under BSD-3-Clause.
* See file 'LICENSE' for full license details.
2020-05-07 18:40:35 +02:00
* Created by Timo Hocker <timo@scode.ovh>, May 2020
2020-04-16 07:45:48 +02:00
*/
2020-04-15 20:21:00 +02:00
import { CopyrightOptions } from './copyright_options';
export class CopyrightGenerator {
public static get_copyright_notice (
opt: CopyrightOptions
): string {
let notice = '';
const date = (new Date);
const dtf = new Intl.DateTimeFormat ('en', { month: 'long' });
const year = date.getFullYear ();
const month = dtf.format (date);
if (opt.has_license) {
notice = `${'/*'}
2020-04-15 20:59:50 +02:00
* Copyright (C) ${opt.company || opt.author} - All Rights Reserved
* This file is part of ${opt.software} which is released under ${
2020-04-15 20:21:00 +02:00
opt.license}.
2020-04-15 20:59:50 +02:00
* See file 'LICENSE' for full license details.
* Created by ${opt.author} <${opt.email}>, ${month} ${year}
*/
`;
2020-04-15 20:21:00 +02:00
}
else {
notice = `${'/*'}
2020-04-15 20:59:50 +02:00
* Copyright (C) ${opt.company || opt.author} - All Rights Reserved
* Created by ${opt.author} <${opt.email}>, ${month} ${year}
*/
`;
2020-04-15 20:21:00 +02:00
}
return notice;
}
}