Skip to content

Latest commit

 

History

History
 
 

lang-js

Lang JS

This directory contains lang-js.

Testing Locally

Here is an example of testing lang-js locally:

DEBUG=* buck2 run :lang-js -- ${CHECK_NAME} < examples/${FILE_NAME}

Encoding the Code

Here is an example of "encoding the code" locally:

cat examples/commandRunFailCode.js | base64 | tr -d '\n'

Example Test Workflow

While dal integration tests are useful for testing new functions and workflows that leverage lang-js, it can be helpful to run lang-js directly for an efficient developer feedback loop.

First, let's author a function and save it to the examples directory.

function fail() {
    throw new Error("wheeeeeeeeeeeeeeee")
}

Now, let's base64 encode this function and save the result to our clipboard.

cat examples/commandRunFailCode.js | base64 | tr -d '\n'

Then, we can create a json file in the same directory that's in a format that lang-js expects.

{
  "executionId": "fail",
  "handler": "fail",
  "codeBase64": "ZnVuY3Rpb24gZmFpbCgpIHsKICAgIHRocm93IG5ldyBFcnJvcigid2hlZWVlZWVlZWVlZWVlZWVlIik7Cn0K"
}

Finally, we can run our function in lang-js directly.

When we run our function in lang-js, let's set the debug flag to see what's going on!

cat examples/commandRunFail.json | DEBUG=* buck2 run :lang-js -- commandRun