-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodemeta-version-ts.tmpl
53 lines (47 loc) · 1.43 KB
/
codemeta-version-ts.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* $package$ information
*/
export const appInfo: {[k: string]: string} = {
// appName holds the application/package name
appName: "$package$",
// Version number of release
version: "$version$",
// ReleaseDate, the date version.ts was generated
releaseDate: "$release_date$",
// ReleaseHash, the Git hash when version.go was generated
releaseHash: "$release_hash$",
// licenseText holds a copy of the application license text.
licenseText: `
$body$
`
}
/**
* fmtHelp lets you process a text block with simple curly brace markup.
* @param {src} src holds the help text to be processed with curly brace
* refernces for app_name, version, release_date, release_hash.
* @returns {string} returns the rendered help text.
*
* @example
* ```
* import { appInfo, fmtHelp } from './version.ts';
*
* const helpText = ` ... this is where you document your program in Pandoc manpage format `;
* console.log(fmtHelp(helpText, appInfo));
* ```
*/
export function fmtHelp(src: string, appInfo: {[k: string]: string}): string {
const terms: { [k: string]: string } = {
app_name: appInfo.appName,
version: appInfo.version,
release_date: appInfo.releaseDate,
release_hash: appInfo.releaseHash
};
for (let key in terms) {
const val: string = terms[key];
const varname: string = ['{', key, '}'].join('');
if (src.indexOf(varname) > -1) {
src = src.replaceAll(varname, val)
}
}
return src
}