Configure line-endings
This commit is contained in:
parent
087d38f570
commit
d885646f39
3 changed files with 24 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { WorkspaceLeaf } from "obsidian";
|
||||
import { Plugin } from "obsidian";
|
||||
import { Platform, Plugin } from "obsidian";
|
||||
import "./styles.scss";
|
||||
import "../manifest.json";
|
||||
import { SyncSettingsTab } from "./views/settings-tab";
|
||||
|
|
@ -37,13 +37,14 @@ export default class VaultLinkPlugin extends Plugin {
|
|||
}
|
||||
|
||||
public async onload(): Promise<void> {
|
||||
this.client = await SyncClient.create(
|
||||
new ObsidianFileSystemOperations(this.app.vault),
|
||||
{
|
||||
this.client = await SyncClient.create({
|
||||
fs: new ObsidianFileSystemOperations(this.app.vault),
|
||||
persistence: {
|
||||
load: this.loadData.bind(this),
|
||||
save: this.saveData.bind(this)
|
||||
}
|
||||
);
|
||||
},
|
||||
nativeLineEndings: Platform.isWin ? "\r\n" : "\n"
|
||||
});
|
||||
|
||||
VaultLinkPlugin.registerConsoleForLogging(this.client);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,16 +40,22 @@ export class SyncClient {
|
|||
return this._database.length;
|
||||
}
|
||||
|
||||
public static async create(
|
||||
fs: FileSystemOperations,
|
||||
public static async create({
|
||||
fs,
|
||||
persistence,
|
||||
fetch = globalThis.fetch,
|
||||
nativeLineEndings = "\n"
|
||||
}: {
|
||||
fs: FileSystemOperations;
|
||||
persistence: PersistenceProvider<
|
||||
Partial<{
|
||||
settings: Partial<SyncSettings>;
|
||||
database: Partial<StoredDatabase>;
|
||||
}>
|
||||
>,
|
||||
fetch: typeof globalThis.fetch = globalThis.fetch
|
||||
): Promise<SyncClient> {
|
||||
>;
|
||||
fetch?: typeof globalThis.fetch;
|
||||
nativeLineEndings?: string;
|
||||
}): Promise<SyncClient> {
|
||||
const logger = new Logger();
|
||||
logger.info("Starting SyncClient");
|
||||
|
||||
|
|
@ -91,7 +97,7 @@ export class SyncClient {
|
|||
database,
|
||||
settings,
|
||||
syncService,
|
||||
new FileOperations(logger, database, fs),
|
||||
new FileOperations(logger, database, fs, nativeLineEndings),
|
||||
history
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ export class MockClient implements FileSystemOperations {
|
|||
public async init(
|
||||
fetchImplementation: typeof globalThis.fetch
|
||||
): Promise<void> {
|
||||
this.client = await SyncClient.create(
|
||||
this,
|
||||
{
|
||||
this.client = await SyncClient.create({
|
||||
fs: this,
|
||||
persistence: {
|
||||
load: async () => this.data,
|
||||
save: async (data) => void (this.data = data)
|
||||
},
|
||||
fetchImplementation
|
||||
);
|
||||
fetch: fetchImplementation
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
Object.keys(this.initialSettings).map(async (key) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue