How to use the lighthouse/lighthouse-cli/chrome-launcher.ChromeLauncher function in lighthouse

To help you get started, we’ve selected a few lighthouse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shakyShane / actor-js / fixtures / launcher.js View on Github external
init() {

        this.launcher = new ChromeLauncher({
            port: 9222,
            autoSelectChrome: true, // False to manually select which Chrome install.
            additionalFlags: ['--headless']
        });

        return fromPromise(this.launcher.run())
            .catch(err => {
                // console.log(err);
                return this.stop();
            });
    }
github ragingwind / chrome-headless-launcher / cli.js View on Github external
$ headless https://google.com --port=9000
	  $ headless https://google.com --screenshot --window-size=1280,1696
`);

if (cli.input.length <= 0) {
	cli.input.push('about:blank');
}

cli.flags.remoteDebuggingPort = cli.flags.port || 9222;

const flags = decamelizeKeys(cli.flags, '-');
const additionalFlags = Object.keys(flags).map(f => {
	return `--${f}${typeof flags[f] !== 'boolean' ? '=' + flags[f] : ''}`;
});

const launcher = new ChromeLauncher({
	startingUrl: cli.input[0],
	port: cli.flags.remoteDebuggingPort,
	autoSelectChrome: true,
	additionalFlags: additionalFlags.concat([
		'--disable-gpu',
		'--headless'
	])
});

// run headless chrome browser
launcher.run().then(() => {
	const debugURL = `http://localhost:${cli.flags.remoteDebuggingPort}`;
	console.log(`Chrome has been ${emoji.get('rocket')} in headless mode. Open ${debugURL} for debugging`);
});

// manage terminating of headless chrome browser
github filamentgroup / node-faux-pas / NodeFauxPas.js View on Github external
NodeFauxPas.prototype._launchChrome = function() {
	const launcher = new ChromeLauncher({
		port: 9222,
		autoSelectChrome: true,
		additionalFlags: ["--disable-gpu", "--headless"]
	});

	return launcher.run().then(() => launcher).catch(err => {
		return launcher.kill().then(() => {
			// Kill Chrome if there's an error.
			throw err;
		}, console.error);
	});
};
github owid / owid-grapher / js / screenshot.js View on Github external
function launchChrome(headless = true) {
  const launcher = new ChromeLauncher({
    port: 9222,
    autoSelectChrome: true, // False to manually select which Chrome install.
    additionalFlags: [
      '--window-size=1020,720',
      '--disable-gpu',
      '--headless'
    ]
  });

  return launcher.run().then(() => launcher)
    .catch(err => {
      return launcher.kill().then(() => { // Kill Chrome if there's an error.
        throw err;
      }, console.error);
    });
}
github qieguo2016 / doffy / src / doffy.js View on Github external
function launchChrome(headless = true) {
  const launcher = new ChromeLauncher({
    port: 9222,
    autoSelectChrome: true, // False to manually select which Chrome install.
    additionalFlags: [
      '--disable-gpu',
      headless ? '--headless' : ''
    ]
  });

  process.on('exit', (code) => {
    // console.log('exit process', code);
    launcher.kill();
  });

  process.on('SIGINT', function(data) {
    // console.log('Got SIGINT.  Press Control-D to exit.', data);
    launcher.kill();
github gcazaciuc / storysnap / src / chrome-launcher.js View on Github external
function launchChrome(url, headless = true) {
  const launchOptions = {
    port: 9222,
    autoSelectChrome: true, // False to manually select which Chrome install.
    additionalFlags: [
      '--window-size=1024,732',
      '--disable-gpu',
      '--hide-scrollbars',
      '--no-sandbox',
      headless ? '--headless' : ''
    ]
  };
  if (url) {
    launchOptions.startingUrl = url;
  }
  launcher = new ChromeLauncher(launchOptions);
  // Also make sure that we wait a little before
  // deciding that we are all good launching
  return launcher.run().then(() => {
      return new Promise((resolve) => setTimeout(() => resolve(launcher), 1000));
  })
    .catch(err => {
      return launcher.kill().then(() => { // Kill Chrome if there's an error.
        throw err;
      }, console.error);
    });
}
github katat / ChromeDiff / index.js View on Github external
createChromeLauncher (options) {
    const flags = []
    flags.push('--disable-gpu')
    if (!options.visible) {
      flags.push('--headless')
    }
    if (options.additionalChromeFlags && Array.isArray(options.additionalChromeFlags)) {
      options.additionalChromeFlags.forEach(f => {
        if (f.indexOf('--') === -1) {
          throw new Error('chrome flag must start "--". flag: ' + f)
        }
        flags.push(f)
      })
    }
    return new ChromeLauncher({
      port: options.port,
      autoSelectChrome: true,
      additionalFlags: flags
    })
  }
  async close () {