Skip to content

Instantly share code, notes, and snippets.

@tmeasday
Last active August 8, 2019 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmeasday/011509260eaeac9434f32dce41115dc5 to your computer and use it in GitHub Desktop.
Save tmeasday/011509260eaeac9434f32dce41115dc5 to your computer and use it in GitHub Desktop.
const { executablePath, args } = require('chrome-aws-lambda');
const { spawnSync,execSync } = require('child_process');
const fullArgs = args.concat(['--no-sandbox', '--headless', '--disable-gpu', '--screenshot', 'https://kqdbudnrfd.tunnel.chromaticqa.com/iframe.html?selectedKind=basics%2FA&selectedStory=fonts']);
console.log('runningWithArgs: ' + fullArgs);
const screenshotResult = spawnSync(executablePath, fullArgs, { cwd: '/tmp', timeout: 25 * 1000 });
console.log('chrome command stdio: ' + screenshotResult.output.toString());
console.log('chrome command stderr: ' + screenshotResult.stderr.toString());
const uploadCommand = 'curl -v -X POST "https://imgur.com/upload" -H "Referer: https://imgur.com/upload" -F "Filedata=@"./screenshot.png";filename=portrait.png;type=image/png"'
const uploadResult = execSync(uploadCommand, { cwd: '/tmp', timeout: 25 * 1000 });
uploadResult.toString('utf8');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment