diff --git a/README.md b/README.md
index 12b59f4..edb2e56 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@ To update the installed JavaScript engines later on, just run `jsvu` again.
| [**V8**][v8] | `v8` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [**V8 debug**][v8] | `v8-debug` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [**XS**][xs] | `xs` | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ |
+| [**Escargot**][escargot] | `escargot` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
\* JavaScriptCore requires external dependencies to run on Windows:
- On 32-bit Windows, install [iTunes](https://www.apple.com/itunes/download/).
@@ -56,6 +57,7 @@ To update the installed JavaScript engines later on, just run `jsvu` again.
[sm]: https://bugzilla.mozilla.org/show_bug.cgi?id=1336514
[v8]: https://bugs.chromium.org/p/chromium/issues/detail?id=936383
[xs]: https://github.com/Moddable-OpenSource/moddable-xst
+[escargot]: https://github.com/Samsung/escargot
## Integration with `eshost-cli`
@@ -85,6 +87,7 @@ eshost --add 'SpiderMonkey' jsshell ~/.jsvu/bin/spidermonkey
eshost --add 'V8 --harmony' d8 ~/.jsvu/bin/v8 --args '--harmony'
eshost --add 'V8' d8 ~/.jsvu/bin/v8
eshost --add 'XS' xs ~/.jsvu/bin/xs
+eshost --add 'Escargot' escargot ~/.jsvu/bin/escargot
```
### Windows
@@ -96,6 +99,7 @@ eshost --add "SpiderMonkey" jsshell "%USERPROFILE%\.jsvu\bin\spidermonkey.cmd"
eshost --add "V8 --harmony" d8 "%USERPROFILE%\.jsvu\bin\v8.cmd" --args "--harmony"
eshost --add "V8" d8 "%USERPROFILE%\.jsvu\bin\v8.cmd"
eshost --add "XS" xs "%USERPROFILE%\.jsvu\bin\xs.cmd"
+eshost --add "Escargot" escargot "%USERPROFILE%\.jsvu\bin\escargot.cmd"
```
That’s it! You can now run code snippets in all those engines with a single command:
@@ -117,7 +121,7 @@ However, there are use cases for running jsvu within non-interactive environment
```sh
jsvu --os=linux64 --engines=all
# Equivalent to:
-jsvu --os=linux64 --engines=graaljs,hermes,javascriptcore,quickjs,spidermonkey,v8,xs
+jsvu --os=linux64 --engines=graaljs,hermes,javascriptcore,quickjs,spidermonkey,v8,xs,escargot
```
If the operating system and architecture are not known in advance, the `--os=default` flag attempts to guess the correct value from the running environment. This might not be right for example if running a 32-bit Node.js process on a 64-bit machine.
@@ -145,6 +149,7 @@ jsvu spidermonkey@66.0b13
jsvu v8@7.2.502
jsvu v8-debug@7.1.302
jsvu xs@8.7.0
+jsvu escargot@4.3.0
```
If you pass in an invalid version number, or if the JavaScript engine creators don’t provide a precompiled binary for that specific version, jsvu shows an error.
diff --git a/cli.js b/cli.js
index 47ac45d..3dc23ad 100755
--- a/cli.js
+++ b/cli.js
@@ -117,6 +117,11 @@ const engineChoices = [
value: 'xs',
checked: true,
},
+ {
+ name: 'Escargot',
+ value: 'escargot',
+ checked: true,
+ },
];
const promptEngines = () => {
diff --git a/engines/escargot/extract.js b/engines/escargot/extract.js
new file mode 100644
index 0000000..149b8e6
--- /dev/null
+++ b/engines/escargot/extract.js
@@ -0,0 +1,67 @@
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the “License”);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// .
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an “AS IS” BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+'use strict';
+
+const path = require('path');
+
+const { Installer } = require('../../shared/installer.js');
+const unzip = require('../../shared/unzip.js');
+
+const extract = ({ filePath, binary, alias, os }) => {
+ return new Promise(async (resolve, reject) => {
+ const tmpPath = path.dirname(filePath);
+ await unzip({
+ from: filePath,
+ to: tmpPath,
+ });
+ const installer = new Installer({
+ engine: binary,
+ path: tmpPath,
+ });
+ switch (os) {
+ case 'win32':
+ case 'win64': {
+ installer.installBinary(
+ { 'escargot.exe': `${binary}.exe` },
+ { symlink: false }
+ );
+ installer.installScript({
+ name: `${binary}.cmd`,
+ generateScript: (targetPath) => {
+ return `
+ @echo off
+ "${targetPath}\\escargot.exe" %*
+ `;
+ }
+ });
+ break;
+ }
+ case 'mac64':
+ case 'mac64arm': {
+ installer.installLibraryGlob('*.dylib');
+ installer.installBinary({ 'escargot': binary }, { symlink: true });
+ break;
+ }
+ case 'linux32':
+ case 'linux64': {
+ installer.installLibraryGlob('*.so.*');
+ installer.installBinary({ 'escargot': binary }, { symlink: true });
+ break;
+ }
+ }
+ resolve();
+ });
+};
+
+module.exports = extract;
\ No newline at end of file
diff --git "a/engines/escargot/get-latest-version.js\342\200\216.js" "b/engines/escargot/get-latest-version.js\342\200\216.js"
new file mode 100644
index 0000000..f5c3b36
--- /dev/null
+++ "b/engines/escargot/get-latest-version.js\342\200\216.js"
@@ -0,0 +1,28 @@
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the “License”);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// .
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an “AS IS” BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+'use strict';
+
+const get = require('../../shared/get.js');
+
+const getLatestVersion = async () => {
+ const url = 'https://api.github.com/repos/Samsung/escargot/releases/latest';
+ const response = await get(url, {
+ json: true,
+ });
+ const data = response.body;
+ const version = data.tag_name.replace(/^v/, '');
+ return version;
+};
+
+module.exports = getLatestVersion;
\ No newline at end of file
diff --git a/engines/escargot/get-specific-version.js b/engines/escargot/get-specific-version.js
new file mode 100644
index 0000000..738b0f8
--- /dev/null
+++ b/engines/escargot/get-specific-version.js
@@ -0,0 +1,23 @@
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the “License”);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// .
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an “AS IS” BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+'use strict';
+
+const getSpecificVersion = (version) => {
+ // If we ever want to add logic that maps e.g. `'2019-08'` to the
+ // latest available version in that range (e.g. `'2019-08-18'`), it
+ // can go here.
+ return version;
+};
+
+module.exports = getSpecificVersion;
\ No newline at end of file
diff --git a/engines/escargot/index.js b/engines/escargot/index.js
new file mode 100644
index 0000000..f837b95
--- /dev/null
+++ b/engines/escargot/index.js
@@ -0,0 +1,20 @@
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the “License”);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// .
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an “AS IS” BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+'use strict';
+
+module.exports = {
+ name: 'Escargot',
+ id: 'escargot',
+ alias: false,
+};
\ No newline at end of file
diff --git a/engines/escargot/predict-url.js b/engines/escargot/predict-url.js
new file mode 100644
index 0000000..7823618
--- /dev/null
+++ b/engines/escargot/predict-url.js
@@ -0,0 +1,48 @@
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the “License”);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// .
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an “AS IS” BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+'use strict';
+
+const predictFileName = (os) => {
+ switch (os) {
+ case 'win32': {
+ return 'win-x86';
+ }
+ case 'win64': {
+ return 'win-x64';
+ }
+ case 'linux32': {
+ return 'linux-x86';
+ }
+ case 'linux64': {
+ return 'linux-x64';
+ }
+ case 'mac64':
+ case 'mac64arm': {
+ return os;
+ }
+ default: {
+ throw new Error(
+ `Escargot does not offer precompiled ${os} binaries.`
+ );
+ }
+ }
+};
+
+const predictUrl = (version, os) => {
+ const fileName = predictFileName(os);
+ const url = `https://github.com/Samsung/escargot/releases/download/v${version}/escargot-${fileName}.zip`;
+ return url;
+};
+
+module.exports = predictUrl;
\ No newline at end of file
diff --git a/engines/escargot/test.js b/engines/escargot/test.js
new file mode 100644
index 0000000..ac1e794
--- /dev/null
+++ b/engines/escargot/test.js
@@ -0,0 +1,36 @@
+// Copyright 2019 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the “License”);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// .
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an “AS IS” BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+'use strict';
+
+const fs = require('fs');
+
+const execa = require('execa');
+const tempy = require('tempy');
+
+const config = require('../../shared/config.js');
+const jsvuBinPath = config.binPath;
+
+const test = async ({ binary }) => {
+ const path = tempy.file();
+ const program = `print('Hi!');\n`;
+ fs.writeFileSync(path, program);
+ console.assert(
+ (await execa(`${jsvuBinPath}/${binary}`, ['-f', path])).stdout === 'Hi!'
+ );
+ console.assert(
+ (await execa(`${jsvuBinPath}/${binary}`, ['-e', program])).stdout === 'Hi!'
+ );
+};
+
+module.exports = test;
\ No newline at end of file
diff --git a/package.json b/package.json
index 837151a..3d1522e 100644
--- a/package.json
+++ b/package.json
@@ -22,12 +22,12 @@
},
"scripts": {
"test": "echo 'Use `npm run test-$os` where `$os` reflects your system.'; echo 'See `npm run` for the full list.' && exit 1",
- "test-mac64": "npm link; jsvu --os=mac64 --engines=all && echo '{\"os\":\"mac64\",\"engines\":[\"hermes\",\"javascriptcore\",\"spidermonkey\",\"v8\"],\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
- "test-mac64arm": "npm link; jsvu --os=mac64arm --engines=all && echo '{\"os\":\"mac64arm\",\"engines\":[\"hermes\",\"javascriptcore\",\"spidermonkey\",\"v8\"],\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
- "test-linux32": "npm link; jsvu --os=linux32 --engines=all && echo '{\"os\":\"linux32\",\"engines\":[\"javascriptcore\",\"spidermonkey\",\"v8\"],\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
- "test-linux64": "npm link; jsvu --os=linux64 --engines=all && echo '{\"os\":\"linux64\",\"engines\":[\"hermes\",\"javascriptcore\",\"quickjs\",\"spidermonkey\",\"v8\"],\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
- "test-win32": "npm link; jsvu --os=win32 --engines=all && echo '{\"os\":\"win32\",\"engines\":[\"javascriptcore\",\"spidermonkey\",\"v8\"],\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
- "test-win64": "npm link; jsvu --os=win64 --engines=all && jsvu && echo '{\"os\":\"win64\",\"engines\":[\"hermes\",\"javascriptcore\",\"spidermonkey\",\"v8\"],\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu"
+ "test-mac64": "npm link; jsvu --os=mac64 --engines=all && echo '{\"os\":\"mac64\",\"engines\":[\"chakra\",\"hermes\",\"javascriptcore\",\"spidermonkey\",\"v8\",\"escargot\"],\"chakra\":\"0\",\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
+ "test-mac64arm": "npm link; jsvu --os=mac64arm --engines=all && echo '{\"os\":\"mac64arm\",\"engines\":[\"chakra\",\"hermes\",\"javascriptcore\",\"spidermonkey\",\"v8\",\"escargot\"],\"chakra\":\"0\",\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
+ "test-linux32": "npm link; jsvu --os=linux32 --engines=all && echo '{\"os\":\"linux32\",\"engines\":[\"chakra\",\"javascriptcore\",\"spidermonkey\",\"v8\",\"escargot\"],\"chakra\":\"0\",\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
+ "test-linux64": "npm link; jsvu --os=linux64 --engines=all && echo '{\"os\":\"linux64\",\"engines\":[\"chakra\",\"hermes\",\"javascriptcore\",\"quickjs\",\"spidermonkey\",\"v8\",\"escargot\"],\"chakra\":\"0\",\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
+ "test-win32": "npm link; jsvu --os=win32 --engines=all && echo '{\"os\":\"win32\",\"engines\":[\"chakra\",\"javascriptcore\",\"spidermonkey\",\"v8\"],\"chakra\":\"0\",\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu",
+ "test-win64": "npm link; jsvu --os=win64 --engines=all && jsvu && echo '{\"os\":\"win64\",\"engines\":[\"chakra\",\"hermes\",\"javascriptcore\",\"spidermonkey\",\"v8\"],\"chakra\":\"0\",\"javascriptcore\":\"0\",\"spidermonkey\":\"0\",\"v8\":\"0\"}' > ~/.jsvu/status.json && jsvu"
},
"author": {
"name": "Mathias Bynens",
@@ -37,6 +37,8 @@
"keywords": [
"javascript engines",
"installer",
+ "chakra",
+ "chakracore",
"javascriptcore",
"jsc",
"spidermonkey",