{"id":13452001,"url":"https://github.com/bterlson/eshost-cli","last_synced_at":"2025-04-06T03:07:31.862Z","repository":{"id":3426077,"uuid":"49461933","full_name":"bterlson/eshost-cli","owner":"bterlson","description":"Run ECMAScript code uniformly across any ECMAScript host","archived":false,"fork":false,"pushed_at":"2024-03-27T03:43:30.000Z","size":438,"stargazers_count":201,"open_issues_count":21,"forks_count":17,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T02:06:56.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bterlson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-11T23:45:51.000Z","updated_at":"2025-03-15T07:21:54.000Z","dependencies_parsed_at":"2024-07-31T07:13:49.815Z","dependency_job_id":null,"html_url":"https://github.com/bterlson/eshost-cli","commit_stats":{"total_commits":183,"total_committers":14,"mean_commits":"13.071428571428571","dds":"0.45355191256830596","last_synced_commit":"7fed7911aee5375fe052bf2ff48fe073960029e6"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bterlson%2Feshost-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bterlson%2Feshost-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bterlson%2Feshost-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bterlson%2Feshost-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bterlson","download_url":"https://codeload.github.com/bterlson/eshost-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T07:01:09.703Z","updated_at":"2025-04-06T03:07:31.838Z","avatar_url":"https://github.com/bterlson.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# eshost-cli\n\n[![Travis Build Status](https://travis-ci.org/bterlson/eshost-cli.svg?branch=master)](https://travis-ci.org/bterlson/eshost-cli)\n[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/bterlson/eshost-cli?branch=master\u0026svg=true)](https://ci.appveyor.com/project/bterlson/eshost-cli)\n\n\neshost-cli makes it easy to run and compare ECMAScript code uniformly across a number of runtimes. Support for runtimes is provided by the library [eshost](https://github.com/bterlson/eshost). Every host is initialized with the [eshost runtime API](https://github.com/bterlson/eshost#runtime-library) available which provides a uniform way to print, create realms, and eval code. \n\nSee eshost's [supported hosts](https://github.com/bterlson/eshost#supported-hosts) for a list of hosts, download/build locations, and other information.\n\n## Usage\n\nSee `--help` output for the full details. Basic usage:\n\n* Add hosts using `eshost --add \u003chost name\u003e \u003chost type\u003e \u003chost path\u003e --args \u003coptional arguments\u003e`.\n* Automatically configure [`esvu`](https://github.com/devsnek/esvu)-installed hosts using `eshost --configure-esvu`.\n* Automatically configure [`jsvu`](https://github.com/GoogleChromeLabs/jsvu)-installed hosts using `eshost --configure-jsvu`.\n* Evaluate a *single* expression using `-e`: `eshost -e \"[1,2,3].length\"`.\n* Execute a multi-statement program using `-x`: `eshost -x \"foo = 42; print(foo);\"`\n* Execute a script using `eshost path/to/script.js`.\n* Execute an expression or multi-statement program as module code using `-m`: \n  - `eshost -me \"foo = 42\"` (this example should result in errors!)\n  - `eshost -mx \"foo = 42; print(foo);\"` (this example should result in errors!)\n* Execute a source file as module code by saving the file with an `.mjs` extension: `eshost file.mjs`; or by using the `-m` option: `eshost -m file.js`\n\n### Install and Configure Hosts\n\n#### Linux and macOS\n\nManually, using `esvu`:\n\n```sh\nnpm install esvu -g;\nexport PATH=\"${HOME}/.esvu/bin:${PATH}\";\n\nesvu --engines=all;\n\nexport ESHOST_PATH_CHAKRA=`which chakra`;\nexport ESHOST_PATH_ENGINE262=`which engine262`;\nexport ESHOST_PATH_HERMES=`which hermes`;\nexport ESHOST_PATH_JAVASCRIPTCORE=`which javascriptcore`;\nexport ESHOST_PATH_QUICKJS=`which qjs-for-eshost`;\nexport ESHOST_PATH_SPIDERMONKEY=`which spidermonkey`;\nexport ESHOST_PATH_V8=`which v8`;\nexport ESHOST_PATH_XS=`which xs`;\n\nnpm install -g eshost-cli;\n\neshost --add \"chakra\" ch $ESHOST_PATH_CHAKRA;\neshost --add \"engine262\" engine262 $ESHOST_PATH_ENGINE262;\neshost --add \"hermes\" hermes $ESHOST_PATH_HERMES;\neshost --add \"javascriptcore\" jsc $ESHOST_PATH_JAVASCRIPTCORE;\neshost --add \"quickjs\" qjs $ESHOST_PATH_QUICKJS;\neshost --add \"spidermonkey\" jsshell $ESHOST_PATH_SPIDERMONKEY;\neshost --add \"v8\" d8 $ESHOST_PATH_V8;\neshost --add \"xs\" xs $ESHOST_PATH_XS;\n```\n\nManually, using `jsvu`: \n\n```sh\n# Engine262\ngit clone https://github.com/devsnek/engine262.git;\ncd engine262 \u0026\u0026 npm install \u0026\u0026 npm run build \u0026\u0026 npm link;\ncd ~/\n\n# Everything else...\nnpm install -g jsvu;\nexport PATH=\"${HOME}/.jsvu:${PATH}\";\n\njsvu --engines=chakra,hermes,javascriptcore,spidermonkey,v8,xs\n\nexport ESHOST_PATH_CHAKRA=`which chakra`;\nexport ESHOST_PATH_ENGINE262=`which engine262`;\nexport ESHOST_PATH_HERMES=`which hermes`;\nexport ESHOST_PATH_JAVASCRIPTCORE=`which javascriptcore`;\nexport ESHOST_PATH_QUICKJS=`which qjs-for-eshost`;\nexport ESHOST_PATH_SPIDERMONKEY=`which spidermonkey`;\nexport ESHOST_PATH_V8=`which v8`;\nexport ESHOST_PATH_XS=`which xs`;\n\nnpm install -g eshost-cli;\n\neshost --add \"chakra\" ch $ESHOST_PATH_CHAKRA;\neshost --add \"engine262\" engine262 $ESHOST_PATH_ENGINE262;\neshost --add \"hermes\" hermes $ESHOST_PATH_HERMES;\neshost --add \"javascriptcore\" jsc $ESHOST_PATH_JAVASCRIPTCORE;\neshost --add \"quickjs\" qjs $ESHOST_PATH_QUICKJS;\neshost --add \"spidermonkey\" jsshell $ESHOST_PATH_SPIDERMONKEY;\neshost --add \"v8\" d8 $ESHOST_PATH_V8;\neshost --add \"xs\" xs $ESHOST_PATH_XS;\n```\n\n##### This will install QuickJS on macOS\n\n```sh\nif [ \"$(uname)\" = Darwin ]; then wget https://bellard.org/quickjs/quickjs-2021-03-27.tar.xz; tar -xf quickjs-2021-03-27.tar.xz;\ncd quickjs-2021-03-27 \u0026\u0026 make; if [ -f \"$PWD/run-test262\" ]; then ln -s $PWD/run-test262 /usr/local/bin/qjs-for-eshost; fi; fi;\n```\n\n\n\n#### Windows\n\n\n\nManually, using `jsvu`: \n\n```batch\ngit clone https://github.com/devsnek/engine262.git\ncd .\\engine262\nnpm install\nnpm run build\nnpm link\nset NPM_GLOBAL_MODULE_PATH=%APPDATA%\\npm\\\nset PATH=%PATH;%NPM_GLOBAL_MODULE_PATH%\nwhere engine262\n\nnpm install jsvu\n\njsvu --os=win64 --engines=\"chakra,spidermonkey,v8,xs\"\n\nset PATH=%PATH;%USERPROFILE%\\.jsvu\\\nset ESHOST_CHAKRA=%USERPROFILE%\\.jsvu\\chakra.cmd\nset ESHOST_ENGINE262=%NPM_GLOBAL_MODULE_PATH%\\engine262.cmd\nset ESHOST_SPIDERMONKEY=%USERPROFILE%\\.jsvu\\spidermonkey.cmd\nset ESHOST_V8=%USERPROFILE%\\.jsvu\\v8.cmd\nset ESHOST_XS=%USERPROFILE%\\.jsvu\\xs.cmd\n\nnpm install -g eshost-cli;\n\neshost --add \"chakra\" ch %ESHOST_CHAKRA%\neshost --add \"engine262\" engine262 %ESHOST_ENGINE262%\neshost --add \"spidermonkey\" jsshell %ESHOST_SPIDERMONKEY%\neshost --add \"v8\" d8 %ESHOST_V8%\neshost --add \"xs\" xs %ESHOST_XS%\n```\n\n### Examples\n\n```console\n$ npm install -g eshost-cli\n$ eshost --help\n$ eshost --add \u003cname\u003e \u003ctype\u003e \u003cpath to host executable\u003e --args \u003coptional arguments\u003e\n$ eshost -e \"Map.length\"\n#### chakra\n0\n\n#### engine262\n0\n\n#### javascriptcore\n0\n\n#### spidermonkey\n0\n\n#### v8\n0\n\n#### xs\n0\n```\n\n\n```console\n$ eshost --configure-esvu --esvu-prefix esvu\n$ eshost --tags esvu-web -itsx \"let a = 40+2; print(a)\"\n\n## Source\nlet a = 40+2; print(a)\n\n┌──────────┬────┐\n│ esvu-ch  │ 42 │\n│ esvu-jsc │    │\n│ esvu-sm  │    │\n│ esvu-v8  │    │\n└──────────┴────┘\n```\n\n```console\n$ eshost --configure-jsvu --jsvu-prefix jsvu\n$ eshost --tags jsvu-web -itsx \"let a = 40+2; print(a)\"\n\n## Source\nlet a = 40+2; print(a)\n\n┌──────────┬────┐\n│ jsvu-ch  │ 42 │\n│ jsvu-jsc │    │\n│ jsvu-sm  │    │\n│ jsvu-v8  │    │\n└──────────┴────┘\n```\n\n### Rules For Module Code\n\nFiles containing the imported modules must be located in the same directory that the \"entry point\" file is located. Please read and accept the following examples.\n\n1. Executing a program with module dependencies, where the entry point is a \".mjs\" file: \n\n    ```sh\n    mkdir entry-point-mjs;\n    cd entry-point-mjs;\n    echo \"export var a = 1;\" \u003e\u003e export.mjs\n    echo \"import {a} from './export.mjs'; print(a);\" \u003e\u003e import.mjs\n\n    eshost --host=\"engine262,javascriptcore,spidermonkey,v8,xs\" import.mjs\n    #### engine262\n    1\n\n    #### javascriptcore\n    1\n\n    #### spidermonkey\n    1\n\n    #### v8\n    1\n\n    #### xs\n    1\n    ```\n\n2. Executing a program with module dependencies, where the entry point is a \".js\" file (Notice the use of the `-m` flag, **this is required for \".js\" files**): \n\n    ```sh\n    mkdir entry-point-js;\n    cd entry-point-js;\n    echo \"export var a = 1;\" \u003e\u003e export.mjs\n    echo \"import {a} from './export.mjs'; print(a);\" \u003e\u003e import.js\n\n    eshost --host=\"engine262,javascriptcore,spidermonkey,v8,xs\" -m import.js\n    #### engine262\n    1\n\n    #### javascriptcore\n    1\n\n    #### spidermonkey\n    1\n\n    #### v8\n    1\n\n    #### xs\n    1\n    ```\n\n**Executing a multi-line program with module dependencies is not yet supported. Support is in progress.**\n\n\n## Managing Hosts\n\nYou can `--list`, `--add`, `--edit`, and `--delete` hosts. Adding a host requires a name, type, and path to the runtime executable. You can optionally pass arguments using `--args`. The same host can be added multiple times with different `--args` which makes it easy to compare the output of runtimes given different options (e.g. by turning language features on and off).\n\nConsole hosts are either provided by the browser vendors or, more likely, built from source. [The `jsvu` CLI](https://github.com/GoogleChromeLabs/jsvu) makes it easy to install and update the most common JavaScript engine binaries.\n\nHost types are [those provided by eshost](https://github.com/bterlson/eshost#eshostcreateagenttype-string-options---agent), namely:\n\n### Shells\n\n| Host Type | All Acceptable `type` Values |\n| ---- | -------------------- |\n| ChakraCore | `chakra`, `ch` |\n| Engine262 | `engine262` |\n| JavaScriptCore | `javascriptcore`, `jsc` |\n| Nashorn | `nashorn` |\n| Node | `node` |\n| QuickJS | `qjs` \u003csup\u003e1\u003c/sup\u003e |\n| SpiderMonkey | `jsshell`, `spidermonkey`, `sm` |\n| V8 | `d8`, `v8` |\n| XS | `xs` |\n\n* 1: **DO NOT USE `~/.jsvu/quickjs` WITH ESHOST-CLI**. The main `quickjs` binary does not support the [eshost runtime API](https://github.com/bterlson/eshost#runtime-library). For more, see [Install and Configure Hosts](#install-and-configure-hosts).\n\n### Browsers\n\n| Host Type | All Acceptable `type` Values |\n| ---- | -------------------- |\n| chrome | `chrome` |\n| edge | `edge` |\n| firefox | `firefox` |\n| safari | `safari` |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbterlson%2Feshost-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbterlson%2Feshost-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbterlson%2Feshost-cli/lists"}