|
|
@ -1,7 +1,6 @@ |
|
|
|
import {platform} from 'os'; |
|
|
|
import {spawn} from 'child_process'; |
|
|
|
import logger from '@wdio/logger'; |
|
|
|
// @ts-expect-error: Missing types
|
|
|
|
import {binary} from 'deno-prebuilt'; |
|
|
|
|
|
|
|
import {Platform, Result} from './types.js'; |
|
|
|
|
|
|
@ -10,18 +9,20 @@ const log = logger('fetch-compare'); |
|
|
|
export default class PlatformDeno implements Platform { |
|
|
|
async run(ctx: Record<string, any>, file: string): Promise<Result> { |
|
|
|
const child = spawn( |
|
|
|
binary, |
|
|
|
platform() === 'win32' ? 'deno.exe' : 'deno', |
|
|
|
['run', '--allow-read', '--allow-net=httpbin.org', 'index-deno.js', file], |
|
|
|
{cwd: ctx.fixturesPath}, |
|
|
|
{cwd: ctx.fixturesPath, stdio: ['pipe', 'pipe', 'inherit']}, |
|
|
|
); |
|
|
|
const stdout = await new Promise((resolve, reject) => { |
|
|
|
child.once('error', reject); |
|
|
|
child.once('exit', reject); |
|
|
|
let stdout = ''; |
|
|
|
child.stdout.on('data', (data) => { |
|
|
|
stdout += data; |
|
|
|
}); |
|
|
|
child.once('exit', () => { |
|
|
|
child.once('error', reject); |
|
|
|
child.once('exit', (code) => { |
|
|
|
if (code !== 0) { |
|
|
|
reject(code); |
|
|
|
} |
|
|
|
resolve(stdout); |
|
|
|
}); |
|
|
|
}); |
|
|
|