How to use opener - 10 common examples

To help you get started, we’ve selected a few opener 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 thgh / rollup-plugin-serve / src / index.js View on Github external
generateBundle () {
      if (!running) {
        running = true

        // Log which url to visit
        const url = (options.https ? 'https' : 'http') + '://' + (options.host || 'localhost') + ':' + options.port
        options.contentBase.forEach(base => {
          console.log(green(url) + ' -> ' + resolve(base))
        })

        // Open browser
        if (options.open) {
          if (/https?:\/\/.+/.test(options.openPage)) {
            opener(options.openPage)
          } else {
            opener(url + options.openPage)
          }
        }
      }
    }
  }
github alibaba / rax / packages / atag / config / serve.js View on Github external
generateBundle() {
      if (!running) {
        running = true;

        // Log which url to visit
        const url = 'http://' + options.host + ':' + options.port;
        options.contentBase.forEach(base => {
          console.log(green(url) + ' -> ' + resolve(base));
        });

        // Open browser
        if (options.open) {
          opener(url + options.openPage);
        }

        console.log(chalk.green('Compiled successfully.'));
      }
    }
  };
github th0r / npm-upgrade / src / commands / check.js View on Github external
);
        }
        break;

      case 'homepage':
        // Ask user about this module again
        modulesToUpdate.unshift(outdatedModule);

        if (homepage === undefined) {
          console.log('Trying to find homepage URL...');
          homepage = outdatedModule.homepage = getModuleHomepage(await getModuleInfo(name));
        }

        if (homepage) {
          console.log(`Opening ${strong(homepage)}...`);
          opener(homepage);
        } else {
          console.log(`Sorry, there is no info about homepage URL in the ${strong(name)}'s package.json`);
        }
        break;

      case 'ignore': {
        const {versions, reason} = await askIgnoreFields(latestVersions[name]);
        config.ignore[name] = {versions, reason};
        break;
      }

      case 'finish':
        isUpdateFinished = true;
        break;

      case true:
github th0r / npm-upgrade / src / commands / check.js View on Github external
});

    switch (answer) {
      case 'changelog':
        // Ask user about this module again
        modulesToUpdate.unshift(outdatedModule);

        if (changelogUrl === undefined) {
          console.log('Trying to find changelog URL...');
          changelogUrl =
            outdatedModule.changelogUrl = await findModuleChangelogUrl(name);
        }

        if (changelogUrl) {
          console.log(`Opening ${strong(changelogUrl)}...`);
          opener(changelogUrl);
        } else {
          console.log(
            `Sorry, we haven't found any changelog URL for ${strong(name)} module.\n` +
            `It would be great if you could fill an issue about this here: ${strong(pkg.bugs.url)}\n` +
            'Thanks a lot!'
          );
        }
        break;

      case 'homepage':
        // Ask user about this module again
        modulesToUpdate.unshift(outdatedModule);

        if (homepage === undefined) {
          console.log('Trying to find homepage URL...');
          homepage = outdatedModule.homepage = getModuleHomepage(await getModuleInfo(name));
github GDJiaMi / jm-cli / src / cmds / serve.ts View on Github external
console.log(err)
      return
    }

    const urls = prepareUrls(protocol, host, port)
    message.info(`Server running at ${chalk.cyan(urls.lanUrlForTerminal || urls.localUrlForTerminal)}`)
    message.info(`Static resources is served from ${chalk.cyan(dist)}`)
    if (proxy) {
      const proxyInfo = proxyInfomation(proxy)
      if (proxyInfo) {
        message.info(`Other HTTP requests will proxy to Proxy-Server base on:\n ${chalk.cyan(proxyInfo)}`)
      }
    }

    if (argv.open) {
      opener(urls.localUrlForBrowser)
    }
  }
github th0r / npm-upgrade / src / commands / changelog.js View on Github external
const {moduleName} = opts;

  console.log(`Trying to find changelog URL for ${strong(moduleName)}...`);
  let changelogUrl;
  try {
    changelogUrl = await findModuleChangelogUrl(moduleName);
  } catch (err) {
    if (err.code === 'E404') {
      console.log("Couldn't find info about this module in npm registry");
      return;
    }
  }

  if (changelogUrl) {
    console.log(`Opening ${strong(changelogUrl)}...`);
    opener(changelogUrl);
  } else {
    console.log(
      "Sorry, we haven't found any changelog URL for this module.\n" +
      `It would be great if you could fill an issue about this here: ${strong(pkg.bugs.url)}\n` +
      'Thanks a lot!'
    );
  }
});
github o2oprotocol / digital-identity / index.js View on Github external
setTimeout(() => {
      try{
        const url = `http://${HOST}:${PORT}`
        console.log(`Opening Browser at ${url}`)
        const browser = opener(url)
        browser.unref();
      }catch(err){
        console.log("open browser", err.message);
      }
    }, 4500)
  })
github Wildhoney / Leaflet.FreeDraw / example / server / default.js View on Github external
import http from 'http';
import express from 'express';
import compression from 'compression';
import opener from 'opener';

const app = express();
app.use(compression());

const server = http.createServer(app);
const isHeroku = 'HEROKU_APP_NAME' in process.env;

app.use(express.static(__dirname + '/example'));

const port = process.env.PORT || 5000;
server.listen(port);
!isHeroku && opener(`http://localhost:${port}`);
github Wildhoney / Freelancer / example / server / default.js View on Github external
import http from 'http';
import { Z_BEST_COMPRESSION } from 'zlib';
import express from 'express';
import compression from 'compression';
import opener from 'opener';

const app = express();
const server = http.createServer(app);
const isHeroku = 'HEROKU_APP_NAME' in process.env;

app.use(compression({ level: Z_BEST_COMPRESSION }));
app.use(express.static(`${__dirname}/example`));

const port = process.env.PORT || 5000;
server.listen(port);
!isHeroku && opener(`http://localhost:${port}`);
github nuxt / nuxt.js / packages / cli / src / commands / dev.js View on Github external
      const openerPromises = nuxt.server.listeners.map(listener => opener(listener.url))
      await Promise.all(openerPromises)

opener

Opens stuff, like webpages and files and executables, cross-platform

(WTFPL OR MIT)
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular opener functions