Skip to content

Commit

Permalink
runner: support url as file
Browse files Browse the repository at this point in the history
  • Loading branch information
CanadaHonk committed Dec 8, 2024
1 parent 4c92f8a commit b600624
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "porffor",
"description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
"version": "0.50.21",
"version": "0.50.22",
"author": "CanadaHonk",
"license": "MIT",
"scripts": {},
Expand Down
18 changes: 15 additions & 3 deletions runner/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import fs from 'node:fs';
globalThis.version = '0.50.21';
globalThis.version = '0.50.22';

// deno compat
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
Expand Down Expand Up @@ -94,8 +94,6 @@ if (['precompile', 'run', 'wasm', 'native', 'c', 'flamegraph', 'hotlines', 'debu
}
}

globalThis.file = file;

let source = '', printOutput = false;
if (process.argv.length >= 4) {
let evalIndex = process.argv.indexOf('-e');
Expand Down Expand Up @@ -127,6 +125,20 @@ if (process.argv.length >= 4) {
}
}

if (file.startsWith('https://')) { // https only :)
// rce warning, make user confirm (disabled)
// const rl = (await import('readline')).createInterface({ input: process.stdin, output: process.stdout });
// const ans = await new Promise(resolve => rl.question(`\u001b[1mAre you sure you want to download this URL:\u001b[0m ${file} (y/n)? `, ans => {
// rl.close();
// resolve(ans);
// }));
// if (ans.toLowerCase()[0] !== 'y') process.exit();

source = await (await fetch(file)).text();
}

globalThis.file = file;

if (!file && !source) {
if (process.argv.includes('-v') || process.argv.includes('--version')) {
// just print version
Expand Down
2 changes: 1 addition & 1 deletion test262/history.json

Large diffs are not rendered by default.

0 comments on commit b600624

Please sign in to comment.