Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson committed Jan 14, 2025
1 parent f01ab1e commit a7f489a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lib/faunadb.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const getClient = async (argv) => {
export async function stringExpressionToQuery(expression) {
const faunadb = (await import("faunadb")).default;

// the `runInContext` function from node:vm does not work with all valid FQL
// expressions, including `null` and objects. Wrapping the provided expression
// in an IIFE ensure that all expressions are supported.
const wrappedCode = `(function() { return ${expression} })()`;

return runInContext(wrappedCode, createContext(faunadb.query));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/formatting/codeToAnsi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const { codeToTokensBase, getTheme } = createHighlighter();
* Returns a string with ANSI codes applied to the code. This is a JS port of the
* TypeScript codeToAnsi function from the Shiki library.
* @param {*} code - The code to format.
* @param {"fql" | "log" | "json" | "js"} language - The language of the code.
* @param {"fql" | "log" | "json"} language - The language of the code.
* @returns {string} - The formatted code with ANSI codes applied.
*/
export function codeToAnsi(code, language) {
Expand Down

0 comments on commit a7f489a

Please sign in to comment.