How to use the opn function in opn

To help you get started, we’ve selected a few opn 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 zhongzhi107 / universal-react-starter-kit / tools / open-browser / index.js View on Github external
if (process.platform === 'darwin') {
    try {
      // Try our best to reuse existing tab
      // on OS X Google Chrome with AppleScript
      execSync('ps cax | grep "Google Chrome"');
      execSync(
        `osascript ${path.join(__dirname, './open-chrome.applescript')} ${url}`,
      );
      return true;
    } catch (err) {
      // Ignore errors.
    }
  }
  // Fallback to opn
  try {
    opn(url);
    return true;
  } catch (err) {
    return false;
  }
};
github satya164 / quik / src / quik-cli.js View on Github external
process.exit(1);
    });
} else {
  server({
    root: process.cwd(),
    port: argv.port,
    run: argv.run,
    watch: argv.watch,
  }).listen(argv.port);

  const url = `http://localhost:${argv.port}`;

  console.log(`Quik is serving files at ${chalk.blue(url)}`);

  if (argv.browser) {
    opn(url, { app: argv.browser });
  } else {
    opn(url);
  }
}
github patternplate / patternplate / source / binary / patternplate.js View on Github external
const [, consoleCommand] = input;
		await application.server.run(consoleCommand, settings);
		return {mode: 'console'};
	}

	await application.start();

	if (settings.open) {
		const {host, port} = application.configuration.server;
		const address = `http://${host}:${port}`;
		const explicit = typeof settings.open === 'string';
		const openOptions = explicit ? {app: settings.open} : {};
		const browserName = explicit ? settings.open : 'default browser';
		application.log.info(`Opening ${browserName} at ${address}`);

		opn(address, openOptions)
			.catch(error => {
				application.log.error(error);
				console.log(error.stack);
			});
	}

	return {mode: 'server'};
}
github Sitecore / jss / samples / sitecore-embedded-jss-app / build / start.js View on Github external
server.listen(options.port, options.host, (err) => {
      if (err) {
        reject(err);
        return;
      }

      console.log(`Starting webpack dev server at ${options.uri()}`);
      open(options.uri());
      resolve();
    });
  });
github Sitecore / jss / packages / sitecore-jss-rendering-host / src / devServer.ts View on Github external
(stats) => {
        if (!browserOpened) {
          console.log('opening browser', stats.compilation.compiler.name);
          openBrowser(urlToOpenOnStart).then(() => {
            browserOpened = true;
          });
        }
      }
    );
github coryhouse / fluent2017 / buildScripts / srcServer.js View on Github external
app.listen(port, function(err) {
  if (err) {
    console.log(err);
  } else {
    opn('http://localhost:' + port);
  }
});
github yinxin630 / fiora / build / dev-server.ts View on Github external
app.listen(port, (err) => {
    if (err) {
        console.log(err);
        return;
    }

    if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
        opn(uri);
    }
});
github VladimirIvanin / insales-uploader / lib / tools / browser.js View on Github external
export function startBrowser (url, options) {
  if (options && options.start || options.launch) {
    const _option = _.omit(options, ['start', 'launch']);
    opn(url, options)
  }
}
github react-native-community / cli / packages / cli / src / server / util / launchChrome.js View on Github external
function launchChrome(url: string) {
  opn(url, { app: [getChromeAppName()] }, err => {
    if (err) {
      logger.error('Google Chrome exited with error:', err);
    }
  });
}
github reimagined / resolve / packages / core / resolve-scripts / src / open_browser.js View on Github external
    .then(() => opn(url, { app: process.env.BROWSER }))
    .catch(() => {})

opn

Open stuff like URLs, files, executables. Cross-platform.

MIT
Latest version published 6 years ago

Package Health Score

63 / 100
Full package analysis

Popular opn functions