From 99d81059d0218296208b20dfa37a9ff75a571932 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 19 Aug 2018 22:28:32 +0200 Subject: [PATCH] better common JS compatibility --- src/services/consistency_checks.js | 9 --------- src/services/script.js | 4 +++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 1fa0efd36..44abe110d 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -71,15 +71,6 @@ async function runSyncRowChecks(table, key, errorList) { sync.id IS NULL AND ` + (table === 'options' ? 'isSynced = 1' : '1'), `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(` SELECT entityId diff --git a/src/services/script.js b/src/services/script.js index c64dc9317..f5fbb4d15 100644 --- a/src/services/script.js +++ b/src/services/script.js @@ -129,7 +129,9 @@ async function getScriptBundle(note, root = true, scriptEnv = null, includedNote apiContext.modules['${note.noteId}'] = {}; ${root ? 'return ' : ''}await (async function(exports, module, require, api` + (modules.length > 0 ? ', ' : '') + 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 ? ', ' : '') + modules.map(mod => `apiContext.modules['${mod.noteId}'].exports`).join(', ') + `); `;