From 81b04f6f2feeeb82528ab685e3bc6299ea3e861e Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Tue, 28 Dec 2021 20:59:53 +0100 Subject: [PATCH] npm login -> npm run login --- README.md | 2 +- main.spec.ts | 2 +- main.stealth.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cb3aa01..7002346 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Setup: `npm install && npx playwright install` (downloads {chromium, firefox, webkit} (742 MB) to cache in home ([doc](https://playwright.dev/docs/browsers#managing-browser-binaries))). -Run `npm login` which opens a browser where you can login. When closing the browser, it writes a file `auth.json` containing cookies that should keep you logged in for some time (`expires` in a month?). +Use `npm run login` which opens a browser where you can login. When closing the browser, it writes a file `auth.json` containing cookies that should keep you logged in for some time (`expires` in a month?). Then use `npm start` to run Chrome in headless mode to claim the current free game. If something goes wrong, use `PWDEBUG=1 npm start` to [inspect](https://playwright.dev/docs/inspector). diff --git a/main.spec.ts b/main.spec.ts index 7947664..bd5fa70 100644 --- a/main.spec.ts +++ b/main.spec.ts @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; // only npm dep needed for this import { existsSync } from 'fs'; if (!existsSync('auth.json')) { - console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.'); + console.error('Missing auth.json! Use `npm run login` to login and create this file by closing the opened browser.'); } test.use({ storageState: 'auth.json', diff --git a/main.stealth.js b/main.stealth.js index b770892..386901d 100644 --- a/main.stealth.js +++ b/main.stealth.js @@ -1,7 +1,7 @@ //@ts-check const { existsSync } = require('fs'); if (!existsSync('auth.json')) { - console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.'); + console.error('Missing auth.json! Use `npm run login` to login and create this file by closing the opened browser.'); process.exit(1); } @@ -72,7 +72,7 @@ const newStealthContext = async (browser, contextOptions = {}) => { await page.goto('https://www.epicgames.com/store/en-US/free-games'); await page.click('button:has-text("Accept All Cookies")'); // to not waste screen space in --debug if (await page.locator('a[role="button"]:has-text("Sign In")').count() > 0) { - console.error('Not signed in anymore. Run `npm login` to login again.'); + console.error('Not signed in anymore. Use `npm run login` to login again.'); process.exit(1); } // click on banner to go to current free game. TODO what if there are multiple games?