-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch-data.js
More file actions
26 lines (23 loc) · 962 Bytes
/
Copy pathpatch-data.js
File metadata and controls
26 lines (23 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require('fs');
let file = 'c:/Users/admin/Dropbox/Apps/remotely-save/Croptop/.obsidian/plugins/proxima/src/data/FileManager.ts';
let content = fs.readFileSync(file, 'utf8');
// Fix local array in loadTasks
content = content.replace(
/async loadTasks\(\) \{\s*this\.tasks = \[\];\s*const files =/g,
"async loadTasks() {\n const newTasks: TaskData[] = [];\n const files ="
);
content = content.replace(
/this\.tasks\.push\(\{/g,
"newTasks.push({"
);
content = content.replace(
/tasks\.sort\(\(a, b\) => a\.orderIndex - b\.orderIndex\);\s*tasksStore\.set\(\tasks\);/g,
"newTasks.sort((a, b) => a.orderIndex - b.orderIndex);\n this.tasks = newTasks;\n tasksStore.set(this.tasks);"
);
// In serializeFrontmatter, wrap dates in quotes just in case!
content = content.replace(
/str \+= \`\$\{k\}: \$\{fm\[k\]\}\\n\`;/,
"str += `${k}: \"${fm[k]}\"\\n`;"
);
fs.writeFileSync(file, content);
console.log('Fixed race conditions');