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

TypeScript ora.default函数代码示例

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

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



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

示例1: async

export default async (args: Args, buildPath: string) => {
  const serverOptions = await getServerOptions(args)
  const protocol = serverOptions.https ? 'https' : 'http'
  const url = `${protocol}://${serverOptions.host}:${serverOptions.port}`

  const server = new Server({
    buildPath,
    ...serverOptions,
  })
  await server.listen()

  const spinner = ora()
  spinner.succeed(`Server running on: ${url}`)
}
开发者ID:aranja,项目名称:tux,代码行数:14,代码来源:serve.ts


示例2: async

export default async (args: Args) => {
  args = merge<Args>(
    {
      options: {
        env: {
          NODE_ENV: process.env.NODE_ENV || 'production',
        },
      },
      middleware: [],
    },
    args
  )

  const spinner = ora('Building project').start()
  let result
  try {
    result = await run('build', args)
  } catch (err) {
    spinner.fail('Failed to compile.')
    printBuildError(err)
    process.exit(1)
  }

  const { warnings } = result
  if (warnings.length) {
    spinner.warn('Compiled with warnings.')
    // tslint:disable-next-line:no-console
    console.log(warnings.join('\n\n'))
    // tslint:disable-next-line:no-console
    console.log(
      '\nSearch for the ' +
        chalk.underline(chalk.yellow('keywords')) +
        ' to learn more about each warning.'
    )
    // tslint:disable-next-line:no-console
    console.log(
      'To ignore, add ' +
        chalk.cyan('// eslint-disable-next-line') +
        ' to the line before.\n'
    )
  } else {
    spinner.succeed('Compiled successfully.')
  }
}
开发者ID:aranja,项目名称:tux,代码行数:44,代码来源:build.ts


示例3: async

export default async (args: Args) => {
  const serverOptions = await getServerOptions(args)
  const protocol = serverOptions.https ? 'https' : 'http'
  const url = `${protocol}://${serverOptions.host}:${serverOptions.port}`

  args = merge<Args>(
    {
      options: {
        env: {
          NODE_ENV: process.env.NODE_ENV || 'development',
        },
      },
      middleware: [],
    },
    args
  )

  if (isInteractive) {
    clearConsole()
  }
  const spinner = ora('Compiling project').start()
  let multiCompiler: MultiCompiler
  try {
    multiCompiler = await run('start', args)
  } catch (err) {
    spinner.fail('Failed to compile')
    // tslint:disable:no-console
    console.log()
    console.log(err.stackTrace || err)
    console.log()
    // tslint:enable:no-console
    throw exitProcess(1)
  }

  const server = new Server({
    multiCompiler,
    ...serverOptions,
  })
  await server.listen()

  spinner.succeed(`Development server running on: ${url}`)
  openBrowser(url)

  const building = ora('Waiting for initial compilation to finish').start()
  multiCompiler.plugin('done', (stats: Stats) => {
    if (isInteractive) {
      clearConsole()
    }

    // We have switched off the default Webpack output in WebpackDevServer
    // options so we are going to "massage" the warnings and errors and present
    // them in a readable focused way.
    const messages = formatWebpackMessages(stats.toJson())
    const isSuccessful = !messages.errors.length && !messages.warnings.length
    if (isSuccessful) {
      building.succeed(`Compiled successfully!`)
    }

    // If errors exist, only show errors.
    if (messages.errors.length) {
      // Only keep the first error. Others are often indicative
      // of the same problem, but confuse the reader with noise.
      if (messages.errors.length > 1) {
        messages.errors.length = 1
      }
      building.fail(`Failed to compile`)
      // tslint:disable-next-line:no-console
      console.log(messages.errors.join('\n\n'))
      return
    }

    // Show warnings if no errors were found.
    if (messages.warnings.length) {
      building.warn('Compiled with warnings')
      // tslint:disable-next-line:no-console
      console.log(messages.warnings.join('\n\n'))

      // Teach some ESLint tricks.
      // tslint:disable-next-line:no-console
      console.log(
        '\nSearch for the ' +
          chalk.underline(chalk.yellow('keywords')) +
          ' to learn more about each warning.'
      )
      // tslint:disable-next-line:no-console
      console.log(
        'To ignore, add ' +
          chalk.cyan('// eslint-disable-next-line') +
          ' to the line before.\n'
      )
    }
  })

  multiCompiler.plugin('invalid', () => {
    if (isInteractive) {
      clearConsole()
    }
    building.text = 'Compiling...'
    building.start()
  })
//.........这里部分代码省略.........
开发者ID:aranja,项目名称:tux,代码行数:101,代码来源:start.ts


示例4: ora

import ora from 'ora'

export default ora()
开发者ID:egoist,项目名称:bubleup,代码行数:3,代码来源:spinner.ts


示例5: async

 return async (options: T) => {
   const spinner = ora(spinnerLabel);
   spinner.start();
   try {
     await fn(options);
     spinner.succeed();
   } catch (e) {
     spinner.fail(e);
     if (killProcess) {
       process.exit(1);
     }
   }
 };
开发者ID:grafana,项目名称:grafana,代码行数:13,代码来源:useSpinner.ts


示例6: runTask

async function runTask(name: string, taskFn: () => Promise<any>) {
  const spinner = ora(name);

  try {
    spinner.start();

    await taskFn();

    spinner.succeed();
  } catch (e) {
    spinner.fail();

    throw e;
  }
}
开发者ID:rjokelai,项目名称:platform,代码行数:15,代码来源:util.ts


示例7: async

export const createTestBundle = async (modulePath: string): Promise<TestBundle> => {
    const bundler = browserify(modulePath, {
        // Generate sourcemaps for debugging
        debug: true,
        // Expose the module under this global variable
        standalone: 'moduleUnderTest',
        // rootDir for sourcemaps
        basedir: __dirname + '/../../src',
    })
    bundler.plugin(tsify, { project: __dirname + '/../../tsconfig.test.json' })

    // If running through nyc, instrument bundle for coverage reporting too
    if (process.env.NYC_CONFIG) {
        bundler.transform(babelify.configure({ plugins: [babelPluginIstanbul], extensions: ['.tsx', '.ts'] }))
    }

    const spinner = ora(`Bundling ${modulePath}`)
    bundler.on('file', (file, id) => {
        spinner.text = `Bundling ${id}`
    })
    spinner.start()
    try {
        const bundle = await getStream(bundler.bundle())
        return {
            load(): DOMModuleSandbox {
                const jsdom = new JSDOM('', { runScripts: 'dangerously' }) as JSDOM & {
                    window: { moduleUnderTest: any }
                }
                jsdom.window.eval(bundle)
                return { window: jsdom.window, module: jsdom.window.moduleUnderTest }
            },
        }
    } finally {
        spinner.stop()
    }
}
开发者ID:JoYiRis,项目名称:sourcegraph,代码行数:36,代码来源:unit-test-utils.ts


示例8: ora

import chalk from 'chalk';
import ora from 'ora';
import program from 'commander';

import rename from './redater';

let directoryValue!: string;

program
  .version('0.0.3')
  .description('Rename photos based on their date taken')
  .arguments('<directory>')
  .action(directory => {
    directoryValue = directory;
  });

program.parse(process.argv);

const spinner = ora('Renaming photos').start();
rename(directoryValue, spinner)
  .then(() => {
    spinner.text = 'Renamed';
    spinner.succeed();
  })
  .catch(err => {
    spinner.text = "Photos can't be renamed";
    spinner.fail();
    // tslint:disable-next-line
    console.log(chalk.red(err.stack));
  });
开发者ID:screendriver,项目名称:redater,代码行数:30,代码来源:bin.ts


示例9: Error

(async () => {
  const electronPrebuiltPath = argv.e ? path.resolve(process.cwd(), (argv.e as string)) : locateElectronPrebuilt();
  let electronPrebuiltVersion = argv.v as string;

  if (!electronPrebuiltVersion) {
    try {
      if (!electronPrebuiltPath) throw new Error('electron-prebuilt not found');
      const pkgJson = require(path.join(electronPrebuiltPath, 'package.json'));

      electronPrebuiltVersion = pkgJson.version;
    } catch (e) {
      throw new Error('Unable to find electron-prebuilt\'s version number, either install it or specify an explicit version');
    }
  }

  let rootDirectory = argv.m as string;

  if (!rootDirectory) {
    // NB: We assume here that we're going to rebuild the immediate parent's
    // node modules, which might not always be the case but it's at least a
    // good guess
    rootDirectory = path.resolve(__dirname, '../../..');
    if (!await fs.pathExists(rootDirectory) || !await fs.pathExists(path.resolve(rootDirectory, 'package.json'))) {
      // Then we try the CWD
      rootDirectory = process.cwd();
      if (!await fs.pathExists(rootDirectory) || !await fs.pathExists(path.resolve(rootDirectory, 'package.json'))) {
        throw new Error('Unable to find parent node_modules directory, specify it via --module-dir, E.g. "--module-dir ." for the current directory');
      }
    }
  } else {
    rootDirectory = path.resolve(process.cwd(), rootDirectory);
  }

  let modulesDone = 0;
  let moduleTotal = 0;
  const rebuildSpinner = ora('Searching dependency tree').start();
  let lastModuleName: string;

  const redraw = (moduleName?: string) => {
    if (moduleName) lastModuleName = moduleName;

    if (argv.p) {
      rebuildSpinner.text = `Building modules: ${modulesDone}/${moduleTotal}`;
    } else {
      rebuildSpinner.text = `Building module: ${lastModuleName}, Completed: ${modulesDone}`;
    }
  };

  const rebuilder = rebuild({
    buildPath: rootDirectory,
    electronVersion: electronPrebuiltVersion,
    arch: (argv.a as string) || process.arch,
    extraModules: argv.w ? (argv.w as string).split(',') : [],
    onlyModules: argv.o ? (argv.o as string).split(',') : null,
    force: argv.f as boolean,
    headerURL: argv.d as string,
    types: argv.t ? (argv.t as string).split(',') as ModuleType[] : ['prod', 'optional'],
    mode: argv.p ? 'parallel' : (argv.s ? 'sequential' : undefined),
    debug: argv.b as boolean
  });

  const lifecycle = rebuilder.lifecycle;

  lifecycle.on('module-found', (moduleName: string) => {
    moduleTotal += 1;
    redraw(moduleName);
  });

  lifecycle.on('module-done', () => {
    modulesDone += 1;
    redraw();
  });

  try {
    await rebuilder;
  } catch (err) {
    rebuildSpinner.text = 'Rebuild Failed';
    rebuildSpinner.fail();
    throw err;
  }

  rebuildSpinner.text = 'Rebuild Complete';
  rebuildSpinner.succeed();
})();
开发者ID:electron,项目名称:electron-rebuild,代码行数:84,代码来源:cli.ts


示例10: build

  // Are we in production?
  isProduction: process.env.NODE_ENV === "production",

  // Host to bind the server to
  host: process.env.HOST || "0.0.0.0",

  // Port to start web server on
  port: (process.env.PORT && parseInt(process.env.PORT)) || 3000,

  // WebSocket port (for dev)
  websocketPort:
    (process.env.WS_PORT && parseInt(process.env.WS_PORT)) || undefined,

  // Spinner
  spinner: ora()
};

// Webpack compiler
export const compiler = webpack([serverConfig, clientConfig]);
export const staticCompiler = webpack([staticConfig]);

// Build function
export function build(buildStatic = false) {
  // Determine which compiler to run
  const buildCompiler = buildStatic ? staticCompiler : compiler;

  return new Promise(resolve => {
    buildCompiler.run((e, fullStats) => {
      // If there's an error, exit out to the console
      if (e) {
开发者ID:leebenson,项目名称:cli,代码行数:30,代码来源:app.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ora.promise函数代码示例发布时间:2022-05-25
下一篇:
TypeScript option-t.Option类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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