mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better common JS compatibility
This commit is contained in:
parent
59d5a86110
commit
99d81059d0
@ -71,15 +71,6 @@ async function runSyncRowChecks(table, key, errorList) {
|
|||||||
sync.id IS NULL AND ` + (table === 'options' ? 'isSynced = 1' : '1'),
|
sync.id IS NULL AND ` + (table === 'options' ? 'isSynced = 1' : '1'),
|
||||||
`Missing sync records for ${key} in table ${table}`, errorList);
|
`Missing sync records for ${key} in table ${table}`, errorList);
|
||||||
|
|
||||||
console.log(`
|
|
||||||
SELECT
|
|
||||||
${key}
|
|
||||||
FROM
|
|
||||||
${table}
|
|
||||||
LEFT JOIN sync ON sync.entityName = '${table}' AND entityId = ${key}
|
|
||||||
WHERE
|
|
||||||
sync.id IS NULL AND ` + (table === 'options' ? 'isSynced = 1' : '1'));
|
|
||||||
|
|
||||||
await runCheck(`
|
await runCheck(`
|
||||||
SELECT
|
SELECT
|
||||||
entityId
|
entityId
|
||||||
|
@ -129,7 +129,9 @@ async function getScriptBundle(note, root = true, scriptEnv = null, includedNote
|
|||||||
apiContext.modules['${note.noteId}'] = {};
|
apiContext.modules['${note.noteId}'] = {};
|
||||||
${root ? 'return ' : ''}await (async function(exports, module, require, api` + (modules.length > 0 ? ', ' : '') +
|
${root ? 'return ' : ''}await (async function(exports, module, require, api` + (modules.length > 0 ? ', ' : '') +
|
||||||
modules.map(child => sanitizeVariableName(child.title)).join(', ') + `) {
|
modules.map(child => sanitizeVariableName(child.title)).join(', ') + `) {
|
||||||
${note.content}
|
try {${note.content};} catch (e) { throw new Error("Load of script note \\"${note.title}\\" (${note.noteId}) failed with: " + e.message); }
|
||||||
|
if (!module.exports) module.exports = {};
|
||||||
|
for (const exportKey in exports) module.exports[exportKey] = exports[exportKey];
|
||||||
})({}, apiContext.modules['${note.noteId}'], apiContext.require(${JSON.stringify(moduleNoteIds)}), apiContext.apis['${note.noteId}']` + (modules.length > 0 ? ', ' : '') +
|
})({}, apiContext.modules['${note.noteId}'], apiContext.require(${JSON.stringify(moduleNoteIds)}), apiContext.apis['${note.noteId}']` + (modules.length > 0 ? ', ' : '') +
|
||||||
modules.map(mod => `apiContext.modules['${mod.noteId}'].exports`).join(', ') + `);
|
modules.map(mod => `apiContext.modules['${mod.noteId}'].exports`).join(', ') + `);
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user