• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript opn类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中opn的典型用法代码示例。如果您正苦于以下问题:TypeScript opn类的具体用法?TypeScript opn怎么用?TypeScript opn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了opn类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: handler

export async function handler(
  context: Context,
  argv: { endpoint: string; port: string; web: boolean; serverOnly: boolean },
) {
  const localPlaygroundPath = `/Applications/GraphQL\ Playground.app/Contents/MacOS/GraphQL\ Playground`

  const isLocalPlaygroundAvailable = fs.existsSync(localPlaygroundPath)

  const shouldStartServer =
    argv.serverOnly || argv.web || !isLocalPlaygroundAvailable

  const shouldOpenBrowser = !argv.serverOnly

  if (shouldStartServer) {
    const link = await startServer({
      context,
      endpoint: argv.endpoint,
      port: argv.port,
    })

    if (shouldOpenBrowser) {
      opn(link)
    }
  } else {
    const envPath = getTmpPath()
    fs.writeFileSync(envPath, JSON.stringify(process.env))
    const url = `graphql-playground://?cwd=${process.cwd()}&envPath=${envPath}`
    opn(url, { wait: false })
  }
}
开发者ID:koddsson,项目名称:graphql-cli,代码行数:30,代码来源:playground.ts


示例2: startWithPort

/**
 * @param {Object} options
 * @param {Number} options.port -- port number
 * @param {String} options.host -- hostname string
 * @param {String=} options.page -- page path, ex: "/", "/index.html"
 * @param {(String|String[])} options.browser -- names of browser apps to launch
 * @return {Promise}
 */
function startWithPort(options: ServerOptions) {

  options.port = options.port || 8080;
  options.host = options.host || "localhost";

  console.log('Starting Polyserve on port ' + options.port);

  let app = express();

  let polyserve = makeApp({
    componentDir: options.componentDir,
    packageName: options.packageName,
    root: process.cwd(),
  });

  app.use(apiProxy('localhost', 8421));

  app.get('/', function (req, res) {
    res.redirect(301, `/components/${polyserve.packageName}/`);
  });

  app.use('/components/', polyserve);

  let server = http.createServer(app);
  let serverStartedResolve: (r: any) => void;
  let serverStartedReject: (r: any) => void;
  let serverStartedPromise = new Promise((resolve, reject) => {
    serverStartedResolve = resolve;
    serverStartedReject = reject;
  });

  server = app.listen(options.port, options.host,
      () => serverStartedResolve(server));

  server.on('error', function(err: any) {
    if (err.code === 'EADDRINUSE') {
      console.error(portInUseMessage(options.port));
    }
    serverStartedReject(err);
  });

  let baseUrl = `http://${options.host}:${options.port}/components/${polyserve.packageName}/`;
  console.log(`Files in this directory are available under ${baseUrl}`);

  if (options.page) {
    let url = baseUrl + (options.page === true ? 'index.html' : options.page);
    if (Array.isArray(options.browser)) {
      for (let i = 0; i < options.browser.length; i++)
        opn(url, options.browser[i]);
    }
    else {
      opn(url, options.browser);
    }
  }

  return serverStartedPromise;
}
开发者ID:anandanand84,项目名称:polyserve,代码行数:65,代码来源:start_server.ts


示例3: handleSignIn

/**
 * Start the sign in process by opening CodeSandbox CLI login url, this page
 * will show a token that the user will have to fill in in the CLI
 *
 * @returns
 */
async function handleSignIn() {
  // Open specific url
  info(`Opening ${CLI_LOGIN_URL}`);
  opn(CLI_LOGIN_URL, { wait: false });

  const { authToken } = await inquirer.prompt([
    {
      message: 'Token:',
      name: 'authToken',
      type: 'input',
    },
  ]);

  // We got the token! Ask the server on authorization
  const spinner = ora('Fetching user...').start();
  try {
    const { token, user } = await api.verifyUser(authToken);

    // Save definite token and user to config
    spinner.text = 'Saving user...';
    await cfg.saveUser(token, user);
    spinner.stop();

    return user;
  } catch (e) {
    spinner.stop();
    throw e;
  }
}
开发者ID:ghoullier,项目名称:codesandbox-cli,代码行数:35,代码来源:login.ts


示例4: createMyServer

function createMyServer(port) {

    const server = createSecureServer({ key: privateKey, cert: certificate });
    const url = `https://localhost:${port}`;

    server.addListener('request', request);
    server.listen(port);
    console.log(`Listen port ${port}...`);
    console.log('Available urls:');
    console.log(url);
    const cachePath = join(process.cwd(), '.cache-download');
    if (!existsSync(cachePath)){
        mkdirSync(cachePath);
    }
    getLocales(cachePath).then(() => {
        const localesTimer = setInterval(function() {
            getLocales(cachePath)
                .catch(err => console.log(err))
        }, 60 * 10000);

        localesTimer.unref();
    });

    if (args.openUrl) {
        opn(url);
    }
}
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:27,代码来源:server.ts


示例5: opn

server.get('/open', (req, res, next) => {
    if (!req.query.url) {
        res.send(200);
        return;
    }

    opn(req.query.url);
    res.send(200);
});
开发者ID:thieskek,项目名称:BotFramework-Samples,代码行数:9,代码来源:extension.ts


示例6: openWebPage

/**
 * Open the given web page URL. If no browser keyword is provided, `opn` will use
 * the user's default browser.
 */
function openWebPage(url: string, withBrowser?: string) {
  let openOptions = {
    app: withBrowser
  };
  opn(url, openOptions, (err) => {
    if (err) {
      // log error and continue
      console.error(`ERROR: Problem launching "${openOptions.app || 'default web browser'}".`);
    }
  });
}
开发者ID:matejkosco,项目名称:polyserve,代码行数:15,代码来源:start_server.ts


示例7: opn

  return app.listen(function() {
    app.emit('started');
    var baseUrl = app.get('url').replace(/\/$/, '');
    console.log('Web server listening at: %s', baseUrl);

    if (app.get('loopback-component-explorer')) {
      var explorerPath = app.get('loopback-component-explorer').mountPath;
      console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
    }

    opn( (baseUrl + explorerPath), { app: 'google chrome' } );
  });
开发者ID:Droid-Kree,项目名称:typescript-loopback-playground,代码行数:12,代码来源:server.ts


示例8: reject

    server.listen(devServerOptions.port as number, devServerOptions.host as string, err => {
      if (err) {
        reject()
        return console.log(err)
      }
      resolve()

      /* 补充处理devServer.open配置 */
      if (devServerOptions.open) {
        opn(devUrl)
      }
    })
开发者ID:topud,项目名称:taro,代码行数:12,代码来源:index.ts


示例9: function

PullRequest.prototype.browser = function(user, repo, number) {
    if (number) {
        openUrl(`${config.github_host}${user}/${repo}/pull/${number}`, { wait: false })
    } else {
        openUrl(`${config.github_host}${user}/${repo}/pulls`, { wait: false })
    }
}
开发者ID:gamerson,项目名称:gh,代码行数:7,代码来源:pull-request.ts


示例10: function

Issue.prototype.browser = function(user, repo, number) {
    if (!number) {
        number = ''
    }

    openUrl(`${config.github_host}${user}/${repo}/issues/${number}`, { wait: false })
}
开发者ID:gamerson,项目名称:gh,代码行数:7,代码来源:issue.ts



注:本文中的opn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ora类代码示例发布时间:2022-05-28
下一篇:
TypeScript open类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap