-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathengine262.js
More file actions
63 lines (52 loc) · 1.42 KB
/
engine262.js
File metadata and controls
63 lines (52 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
const assert = require('assert');
const path = require('path');
const fetch = require('node-fetch');
const execa = require('execa');
const Installer = require('../installer');
const { untar } = require('../common');
class Engine262Installer extends Installer {
constructor(...args) {
super(...args);
this.binPath = undefined;
}
static resolveVersion(version) {
if (version === 'latest') {
return fetch('https://registry.npmjs.org/@engine262/engine262')
.then((r) => r.json())
.then((b) => b['dist-tags'].latest);
}
return version;
}
getDownloadURL(version) {
return fetch('https://registry.npmjs.org/@engine262/engine262')
.then((r) => r.json())
.then((b) => b.versions[version].dist.tarball);
}
async extract() {
await untar(this.downloadPath, this.installPath);
}
async install() {
const bin = path.join(this.installPath, 'package', 'lib', 'engine262.js');
this.binPath = await this.registerBinarySymlink(bin, 'engine262');
}
async test() {
const program = 'console.log("42");';
const output = '42';
assert.strictEqual(
(await execa(this.binPath, [], { input: program })).stdout,
output,
);
}
}
Engine262Installer.config = {
name: 'engine262',
id: 'engine262',
externalRequirements: [
{
name: 'Node.js',
url: 'https://nodejs.org/',
},
],
};
module.exports = Engine262Installer;