Hello there!
I’ve had some issue with Obsidian Sync kinda missing some files being modified within .obsidian/ (so settings and stuff, mostly plugin settings), and so I got some headaches trying to have coherent settings between all my devices (mostly my macos laptop and my windows desktop).
To remedy this, I’ve written a small node js
script that recursively inserts an EOL character at the end of each file within the .obsidian folder. I hope this can help anyone that got the same issue that I had!
const fs = require("fs");
const path = require("path");
const acceptedExtensions = [".md", ".txt", ".js", ".css", ".html", ".json"];
function writeEolAtEndOfFile(filePath) {
if (!acceptedExtensions.includes(path.extname(filePath))) return;
fs.appendFileSync(filePath, "\n");
}
function goTroughDirRecursively(dirPath, callback) {
const files = fs.readdirSync(dirPath);
files.forEach((file) => {
const filePath = path.join(dirPath, file);
const stat = fs.statSync(filePath);
if (stat.isDirectory()) {
goTroughDirRecursively(filePath, callback);
} else {
callback(filePath);
}
});
}
// change the path to the folder you want to touch all files in, it can be also be a "normal" fodler with markdown files, relative to where this script is located
// you can also give it an absolute path if need be
goTroughDirRecursively(path.resolve(__dirname, "../../.obsidian"), writeEolAtEndOfFile);