-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovider.template.js
73 lines (66 loc) · 2.75 KB
/
provider.template.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* This file is generated by VSCode extension: Fileheader Pro
*/
/**
* These comments can help you write your own template with type hint
* @typedef {Object} FileheaderVariable Fileheader variables
* @property {string} birthtime file birth time. will get it from VCS or fallback to filesystem when it is not available
* @property {string} mtime file modification time. will get it from VCS or fallback to filesystem when it is not available
* @property {string} authorName if the file is tracked by VCS, it will get the author name from VCS. else it will get it from current user name
* @property {string} authorEmail if the file is tracked by VCS, it will get the author email from VCS. else it will get it from current user email
* @property {string} userName else it will get it from current user name
* @property {string} userEmail user email is from VSCode config, and fallback to VCS config
* @property {string} companyName
* @property {string} projectName name of current project
* @property {string} filePath the file path, relative to project root with POSIX path separator
* @property {string} dirPath the directory path, relative to project root with POSIX path separator
* @property {string} fileName filename with extension
*/
/**
* @typedef {string | number | null | undefined | Template | boolean} TemplateInterpolation NOTE: boolean or falsy value will render empty string
*
* @typedef {{ strings: TemplateStringsArray; interpolations: TemplateInterpolation[]; }} Template
* @typedef {(strings: TemplateStringsArray, ...values: any[]) => string} ITemplateFunction
*
*/
/**
* Please confirm your provider extends from globalThis.FileheaderLanguageProvider
*/
class CustomLanguageProvider extends globalThis.FileheaderLanguageProvider {
/**
* @type {string[]}
*/
languages = [
"javascript",
"typescript",
"javascriptreact",
"typescriptreact",
];
/**
* @type {string=} the language block comment start string.
* this is for future feature: support detect old custom template when custom template changes
*/
blockCommentStart = "/*";
/**
* @type {string=}
*/
blockCommentEnd = "*/";
/**
* get your template when document language matched
* @param {ITemplateFunction} tpl template function, it is a tagged function, support nested interpolation
* @param {FileheaderVariable} variables template variables
* @returns {Template}
*/
getTemplate(tpl, variables) {
// prettier-ignore
return tpl
`/*
* @author ${variables.authorName} <${variables.authorEmail}>
* @date ${variables.birthtime}
* @lastModified ${variables.mtime}
* Copyright © ${variables.companyName} All rights reserved
*/`;
}
}
// export your provider classes
module.exports = [CustomLanguageProvider];