Skip to content

Commit

Permalink
refactor: use modules
Browse files Browse the repository at this point in the history
ludovicm67 committed Feb 29, 2024
1 parent 8c12bbe commit f53bf1c
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
"version": "0.1.0",
"description": "List all available properties per browser for getStats",
"main": "src/index.js",
"type": "module",
"scripts": {
"start": "node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
6 changes: 2 additions & 4 deletions src/browsers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { chromium, firefox } = require("playwright");
import { chromium, firefox } from "playwright";

const browsers = [
export const browsers = [
{
name: "Chromium",
browser: chromium,
@@ -26,5 +26,3 @@ const browsers = [
permissions: [],
},
];

module.exports = browsers;
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require("fs");
const browsers = require("./browsers");
import fs from "fs";
import { browsers } from "./browsers.js";

const waitSeconds = async (seconds) => {
await new Promise((r) => setTimeout(r, seconds * 1000));
@@ -40,7 +40,7 @@ const deviceFromResult = (r) => {
};
};

(async () => {
const main = async () => {
const results = await Promise.all(
browsers.map((browser) => runBrowser(browser))
);
@@ -80,4 +80,6 @@ const deviceFromResult = (r) => {

// print results in the console
console.log(results);
})();
};

await main();

0 comments on commit f53bf1c

Please sign in to comment.