Skip to content

Commit

Permalink
fixing lints
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams committed Oct 29, 2023
1 parent f028255 commit abc592b
Showing 1 changed file with 58 additions and 56 deletions.
114 changes: 58 additions & 56 deletions src/engines/boa.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,79 @@
'use strict';

const assert = require('assert');
const execa = require('execa');
const { join } = require('path');
const fetch = require('node-fetch');
const { copyFileSync, chmodSync, existsSync, mkdirSync } = require('fs');
const Installer = require('../installer');
const assert = require('assert');''
const execa = require('execa');''
const { platform } = require('../common');
const { copyFileSync, chmodSync, existsSync, mkdirSync } = require('fs');
const { join } = require('path');

function getFilename() {
switch (platform) {
case 'darwin-x64':
return 'boa-macos-amd64';
case 'linux-x64':
return 'boa-linux-amd64';
case 'win32-x64':
return 'boa-windows-amd64';
default:
throw new Error(`No Boa builds available for ${platform}`);
}
switch (platform) {
case 'darwin-x64':
return 'boa-macos-amd64';
case 'linux-x64':
return 'boa-linux-amd64';
case 'win32-x64':
return 'boa-windows-amd64';
default:
throw new Error(`No Boa builds available for ${platform}`);
}
}

class BoaInstaller extends Installer {
constructor(...args) {
super(...args);
this.binPath = undefined;
}
constructor(...args) {
super(...args);
this.binPath = undefined;
}

static resolveVersion(version) {
if (version === 'latest') {
return fetch('https://api.github.com/repos/boa-dev/boa/releases/latest')
.then((r) => r.json())
.then((r) => r.tag_name);
}
return version;
static resolveVersion(version) {
if (version === 'latest') {
return fetch('https://api.github.com/repos/boa-dev/boa/releases/latest')
.then((r) => r.json())
.then((r) => r.tag_name);
}
return version;
}

getDownloadURL(version) {
return `https://github.com/boa-dev/boa/releases/download/${version}/${getFilename()}`;
}
getDownloadURL(version) {
return `https://github.com/boa-dev/boa/releases/download/${version}/${getFilename()}`;
}

async extract() {
// The file is not zipped so we don't need to do any extraction here, instead just moving it to the extractedPath
// The file doesn't seem to be executable so we need to set it manually
chmodSync(this.downloadPath, '755');
// Windows will fail if the extractedPath doesn't exist
if (!existsSync(this.extractedPath)){
mkdirSync(this.extractedPath);
}
return copyFileSync(this.downloadPath, join(this.extractedPath, 'boa'));
async extract() {
// The file is not zipped so we don't need to do any extraction here
// The file doesn't seem to be executable so we need to set it manually
chmodSync(this.downloadPath, '755');
// Windows will fail if the extractedPath doesn't exist
if (!existsSync(this.extractedPath)) {
mkdirSync(this.extractedPath);
}
return copyFileSync(this.downloadPath, join(this.extractedPath, 'boa'));
}

async install() {
this.binPath = await this.registerBinary('boa');
}
async install() {
this.binPath = await this.registerBinary('boa');
}

async test() {
const program = 'console.log("42");';
const output = '42\nundefined';
async test() {
const program = 'console.log("42");';
const output = '42\nundefined';

assert.strictEqual(
(await execa(this.binPath, [], { input: program })).stdout,
output,
);
}
assert.strictEqual(
(await execa(this.binPath, [], { input: program })).stdout,
output,
);
}
}

BoaInstaller.config = {
name: 'Boa',
id: 'boa',
supported: [
'linux-x64',
'win32-x64',
'darwin-x64',
]
name: 'Boa',
id: 'boa',
supported: [
'linux-x64',
'win32-x64',
'darwin-x64',
],
};


module.exports = BoaInstaller;

0 comments on commit abc592b

Please sign in to comment.