-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch-formulas.js
More file actions
27 lines (25 loc) · 1.32 KB
/
Copy pathpatch-formulas.js
File metadata and controls
27 lines (25 loc) · 1.32 KB
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
27
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');
// 1. Inject prop() function into Formula evaluation scope
const oldScope = ` const scope: Record<string, any> = {};
for (const s of this.plugin.settings.taskSchema) {
if (s.name && props[s.id] !== undefined) {
scope[s.name] = props[s.id];
}
}`;
const newScope = ` const scope: Record<string, any> = {
prop: (name: string) => {
const s = this.plugin.settings.taskSchema.find(x => x.name === name || x.id === name);
return s ? props[s.id] : undefined;
}
};
// Also spread properties directly for backwards compatibility
for (const s of this.plugin.settings.taskSchema) {
if (s.name && props[s.id] !== undefined) {
scope[s.name] = props[s.id];
}
}`;
content = content.replace(oldScope, newScope);
fs.writeFileSync(file, content);
console.log('Patched FileManager.ts formula scope');