We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1d85885 commit ca8a08cCopy full SHA for ca8a08c
1 file changed
src/index.ts
@@ -127,9 +127,15 @@ export class Markdown {
127
128
/** 检查是否有传入模板 */
129
if (this.config?.template) {
130
- if (!fs.existsSync(this.config.template)) throw TypeError('Template file not found')
131
- this.templatepath = this.config.template
132
- this.template = fs.readFileSync(this.config.template, 'utf-8')
+ // 判断是文件路径还是模板字符串
+ if (fs.existsSync(this.config.template)) {
+ // 是文件路径
133
+ this.templatepath = this.config.template
134
+ this.template = fs.readFileSync(this.config.template, 'utf-8')
135
+ } else {
136
+ // 是模板字符串
137
+ this.template = this.config.template
138
+ }
139
} else {
140
this.template = fs.readFileSync(this.templatepath, 'utf-8')
141
}
0 commit comments