*Add sandbox command

This commit is contained in:
Derrick Hammer 2022-07-20 13:35:59 -04:00
parent ee4105f3a7
commit 13fbea7051
2 changed files with 22 additions and 1 deletions

View File

@ -2,7 +2,7 @@
"name": "@lumeweb/kernel-tester",
"version": "0.1.0",
"scripts": {
"build": "tsc && rollup -c && cp dist/tester.js public/tester.js && cp build/*.d.ts dist && rm -f dist/tester.js && rm -rf build/"
"build": "tsc && rollup -c && cp dist/tester.js public/tester.js && mkdir -p bin && cp build/sandbox.js bin/sandbox.js && cp build/*.d.ts dist && rm -f dist/tester.js && rm -rf build/"
},
"main": "dist/index.js",
"types": "types",
@ -23,5 +23,8 @@
"rollup": "^2.75.7",
"rollup-plugin-polyfill-node": "^0.9.0",
"typescript": "^4.5"
},
"bin": {
"kernel-sandbox": "bin/sandbox.js"
}
}

18
src/sandbox.ts Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env node
import { loadTester, login } from "../dist/index.js";
import puppeteer, { Browser, Page } from "puppeteer";
let browser: Browser;
(async () => {
browser = await puppeteer.launch({ headless: false, devtools: true });
const page = (await browser.pages()).pop() as Page;
await login(page);
await loadTester(page);
})();
process.on("SIGTERM", async () => {
await browser.close();
});