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 (
|
2020-06-27 19:36:35 +02:00
|
|
|
opt: CopyrightOptions,
|
|
|
|
date_str?: string
|
2020-04-15 20:21:00 +02:00
|
|
|
): string {
|
|
|
|
let notice = '';
|
2020-06-27 19:36:35 +02:00
|
|
|
let date_string = date_str;
|
|
|
|
if (typeof date_str === 'undefined') {
|
|
|
|
const date = (new Date);
|
|
|
|
const dtf = new Intl.DateTimeFormat ('en', { month: 'long' });
|
|
|
|
const year = date.getFullYear ();
|
|
|
|
const month = dtf.format (date);
|
|
|
|
date_string = `${month} ${year}`;
|
|
|
|
}
|
2020-04-15 20:21:00 +02:00
|
|
|
|
|
|
|
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.
|
2020-06-27 19:36:35 +02:00
|
|
|
* Created by ${opt.author} <${opt.email}>, ${date_string}
|
2020-04-15 20:59:50 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
`;
|
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
|
2020-06-27 19:36:35 +02:00
|
|
|
* Created by ${opt.author} <${opt.email}>, ${date_string}
|
2020-04-15 20:59:50 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
`;
|
2020-04-15 20:21:00 +02:00
|
|
|
}
|
|
|
|
return notice;
|
|
|
|
}
|
|
|
|
}
|