mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 09:23:00 +02:00
#364 - Honour file ending rules in data files
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
- [#348](https://github.com/estruyf/vscode-front-matter/issues/348): Fix media dashboard breadcrumb when multiple page folders are in use
|
||||
- [#356](https://github.com/estruyf/vscode-front-matter/issues/356): Re-introduce the `labelField` to the `frontMatter.taxonomy.fieldGroups` setting
|
||||
- [#358](https://github.com/estruyf/vscode-front-matter/issues/358): Fix for relative path of the public folder
|
||||
- [#364](https://github.com/estruyf/vscode-front-matter/issues/364): Honour file ending rules in data files
|
||||
|
||||
## [7.3.4] - 2022-06-13
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { workspace } from 'vscode';
|
||||
import { DataFile } from './../../models/DataFile';
|
||||
import { DashboardMessage } from "../../dashboardWebView/DashboardMessage";
|
||||
import { BaseListener } from "./BaseListener";
|
||||
@@ -30,6 +31,10 @@ export class DataListener extends BaseListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the data update
|
||||
* @param msgData
|
||||
*/
|
||||
private static processDataUpdate(msgData: any) {
|
||||
const { file, fileType, entries } = msgData as { file: string, fileType: string, entries: any[] };
|
||||
|
||||
@@ -41,11 +46,14 @@ export class DataListener extends BaseListener {
|
||||
}
|
||||
}
|
||||
|
||||
const insertFinalNewLine = workspace.getConfiguration().get('files.insertFinalNewline');
|
||||
|
||||
if (fileType === 'yaml') {
|
||||
const yamlData = yaml.safeDump(entries);
|
||||
writeFileSync(absPath, yamlData, 'utf8');
|
||||
writeFileSync(absPath, insertFinalNewLine ? `${yamlData}\n` : yamlData, 'utf8');
|
||||
} else {
|
||||
writeFileSync(absPath, JSON.stringify(entries, null, 2));
|
||||
const jsonData = JSON.stringify(entries, null, 2);
|
||||
writeFileSync(absPath, insertFinalNewLine ? `${jsonData}\n` : jsonData, 'utf8');
|
||||
}
|
||||
|
||||
this.processDataFile(msgData);
|
||||
|
||||
Reference in New Issue
Block a user