添加后缀支持

This commit is contained in:
2021-03-10 01:22:57 +08:00
parent 98f7f074cf
commit b225dbe90c
3 changed files with 4 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import { path } from "tiny/path";
export interface ExporterConfigs { export interface ExporterConfigs {
enabled: boolean, enabled: boolean,
directory: string, directory: string,
extension?: string;
} }
export class TableExporter { export class TableExporter {
@@ -15,7 +16,7 @@ export class TableExporter {
this.configs = configs; this.configs = configs;
} }
get extension(): string { return ''} get extension(): string { return this.configs.extension || ''; }
protected line(text = "", indent = 0) { protected line(text = "", indent = 0) {
return this.indent_text(text, indent) + '\n'; return this.indent_text(text, indent) + '\n';

View File

@@ -17,7 +17,7 @@ export class JSONExporter extends TableExporter {
} }
} }
get extension(): string { return 'json'} get extension(): string { return this.configs.extension || 'json'; }
protected recursively_order_keys(unordered: object | Array<object>) { protected recursively_order_keys(unordered: object | Array<object>) {
// If it's an array - recursively order any // If it's an array - recursively order any

View File

@@ -12,7 +12,7 @@ interface YAMLExporterConfigs extends ExporterConfigs {
export class YAMLExporter extends JSONExporter { export class YAMLExporter extends JSONExporter {
get extension(): string { return 'yaml'} get extension(): string { return this.configs.extension || 'yaml'; }
constructor(configs: ExporterConfigs) { constructor(configs: ExporterConfigs) {
super(configs); super(configs);