vf-oscars-to-csv
Advanced tools
Comparing version 2023.1.0 to 2023.1.1
@@ -8,2 +8,3 @@ "use strict"; | ||
const chrome_aws_lambda_1 = __importDefault(require("chrome-aws-lambda")); | ||
const puppeteer_core_1 = __importDefault(require("puppeteer-core")); | ||
exports.CATEGORY_LIST = [ | ||
@@ -41,2 +42,20 @@ 'BEST PICTURE', | ||
exports.ballotToCsvRow = ballotToCsvRow; | ||
async function getBrowser() { | ||
// https://github.com/orgs/vercel/discussions/124#discussioncomment-569978 | ||
const options = process.env.AWS_REGION | ||
? { | ||
args: chrome_aws_lambda_1.default.args, | ||
executablePath: await chrome_aws_lambda_1.default.executablePath, | ||
headless: chrome_aws_lambda_1.default.headless | ||
} | ||
: { | ||
args: [], | ||
executablePath: process.platform === 'win32' | ||
? 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' | ||
: process.platform === 'linux' | ||
? '/usr/bin/google-chrome' | ||
: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' | ||
}; | ||
return await puppeteer_core_1.default.launch(options); | ||
} | ||
function verifyTitle(title) { | ||
@@ -50,9 +69,3 @@ if (!exports.CATEGORY_LIST.includes(title)) { | ||
console.log('connecting...'); | ||
const browser = await chrome_aws_lambda_1.default.puppeteer.launch({ | ||
args: chrome_aws_lambda_1.default.args, | ||
defaultViewport: chrome_aws_lambda_1.default.defaultViewport, | ||
executablePath: await chrome_aws_lambda_1.default.executablePath, | ||
headless: chrome_aws_lambda_1.default.headless, | ||
ignoreHTTPSErrors: true, | ||
}); | ||
const browser = await getBrowser(); | ||
try { | ||
@@ -59,0 +72,0 @@ const page = await browser.newPage(); |
{ | ||
"name": "vf-oscars-to-csv", | ||
"version": "2023.1.0", | ||
"version": "2023.1.1", | ||
"description": "utility to extract Oscar ballots from Vanity Fair's Interactive Ballot", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -1,2 +0,3 @@ | ||
import chromium from 'chrome-aws-lambda'; | ||
import chrome from 'chrome-aws-lambda'; | ||
import puppeteer, { Browser } from 'puppeteer-core'; | ||
@@ -39,2 +40,22 @@ export const CATEGORY_LIST = [ | ||
async function getBrowser(): Promise<Browser> { | ||
// https://github.com/orgs/vercel/discussions/124#discussioncomment-569978 | ||
const options = process.env.AWS_REGION | ||
? { | ||
args: chrome.args, | ||
executablePath: await chrome.executablePath, | ||
headless: chrome.headless | ||
} | ||
: { | ||
args: [], | ||
executablePath: | ||
process.platform === 'win32' | ||
? 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' | ||
: process.platform === 'linux' | ||
? '/usr/bin/google-chrome' | ||
: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' | ||
}; | ||
return await puppeteer.launch(options); | ||
} | ||
function verifyTitle(title: string): title is typeof CATEGORY_LIST[number] { | ||
@@ -49,9 +70,3 @@ if (!CATEGORY_LIST.includes(title as typeof CATEGORY_LIST[number])) { | ||
console.log('connecting...'); | ||
const browser = await chromium.puppeteer.launch({ | ||
args: chromium.args, | ||
defaultViewport: chromium.defaultViewport, | ||
executablePath: await chromium.executablePath, | ||
headless: chromium.headless, | ||
ignoreHTTPSErrors: true, | ||
}); | ||
const browser = await getBrowser(); | ||
@@ -58,0 +73,0 @@ try { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16297
291
3