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

TypeScript minimist.default函数代码示例

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

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



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

示例1: createConfig

/**
 * @description Create configuration
 *
 * @param {string[]} argv command-line arguments
 * @returns {object} configuration object
 */
function createConfig(rawArgv: string[]) {
    const config = new nconf.Provider(),
        parsedArgv = flat.unflatten(minimist(rawArgv), {delimiter: ':'}),
        envWhitelist = _(process.env)
            .keys()
            .filter(function(key: string) {
                return ENV_DELIMITER_REGEX.test(key) && !/^npm_config/.test(key);
            })
            .valueOf()
            .concat(['loglevel']);

    config.add('argv', {type: 'literal', store: parsedArgv});

    config.env({
        separator: ENV_DELIMITER,
        whitelist: envWhitelist
    });

    return function get(key: string, defaultValue?: any): any {
        var result = coerceValues(config.get(key));

        if (_.isUndefined(result)) {
            result = defaultValue;
        }

        return result;
    };
}
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:34,代码来源:index.ts


示例2: executeCommandLine

// tslint:disable-next-line:cognitive-complexity
async function executeCommandLine() {
  const argv = minimist(process.argv.slice(2), { '--': true })

  const showVersion = argv.v || argv.version
  if (showVersion) {
    showToolVersion()
    return
  }

  let config: string | undefined = argv.config
  if (!config) {
    config = defaultConfigName
  }
  const configPath = path.resolve(process.cwd(), config)

  const configFileData: ConfigData | ConfigData[] = require(configPath)
  const configDatas = Array.isArray(configFileData) ? configFileData : [configFileData]

  const watchMode: boolean = argv.w || argv.watch

  for (const configData of configDatas) {
    if (!configData.inputFiles || configData.inputFiles.length === 0) {
      throw new Error('Error: no input files.')
    }

    globAsync(configData.inputFiles.length === 1 ? configData.inputFiles[0] : `{${configData.inputFiles.join(',')}}`, configData.excludeFiles).then(uniqFiles => {
      const htmlInputFiles: string[] = []
      const jsCssInputFiles: string[] = []
      const htmlOutputFiles: string[] = []

      for (const file of uniqFiles) {
        if (isHtmlExtension(file)) {
          htmlInputFiles.push(file)
          htmlOutputFiles.push(configData.outputFiles(file))
        } else {
          jsCssInputFiles.push(file)
        }
      }

      if (watchMode) {
        const variables: Variable[] = []
        let count = 0
        chokidar.watch(configData.inputFiles, { ignored: configData.excludeFiles }).on('all', (type: string, file: string) => {
          console.log(`Detecting ${type}: ${file}`)
          if (type === 'add' || type === 'change') {
            if (isHtmlExtension(file)) {
              const index = htmlInputFiles.findIndex(f => f === file)
              if (index === -1) {
                htmlInputFiles.push(file)
                htmlOutputFiles.push(configData.outputFiles(file))
              } else {
                htmlInputFiles[index] = file
                htmlOutputFiles[index] = configData.outputFiles(file)
              }
              count++
              if (count > uniqFiles.length) {
                revisionHtml(htmlInputFiles, htmlOutputFiles, variables, configData)
              } else if (count === uniqFiles.length) {
                revisionHtml(htmlInputFiles, htmlOutputFiles, variables, configData)
                writeVariables(configData, variables)
              }
            } else {
              revisionCssOrJs(file, configData).then(variable => {
                const index = variables.findIndex(v => v.file === file)
                if (index === -1) {
                  variables.push(variable)
                } else {
                  const oldVariable = variables[index]
                  if (oldVariable.value && oldVariable.value !== variable.value) {
                    const oldFile = path.resolve(path.dirname(oldVariable.file), oldVariable.value)
                    console.log(`Removing ${oldFile}`)
                    fs.unlink(oldFile, error => {
                      if (error) {
                        console.log(error)
                      }
                    })
                  }
                  variables[index] = variable
                }
                count++

                if (count >= uniqFiles.length) {
                  revisionHtml(htmlInputFiles, htmlOutputFiles, variables, configData)
                  writeVariables(configData, variables)
                }
              })
            }
          } else if (type === 'unlink') {
            if (isHtmlExtension(file)) {
              const index = htmlInputFiles.findIndex(f => f === file)
              if (index !== -1) {
                htmlInputFiles.splice(index, 1)
                htmlOutputFiles.splice(index, 1)
                revisionHtml(htmlInputFiles, htmlOutputFiles, variables, configData)
              }
            } else {
              const index = variables.findIndex(v => v.file === file)
              if (index !== -1) {
                variables.splice(index, 1)
//.........这里部分代码省略.........
开发者ID:plantain-00,项目名称:rev-static,代码行数:101,代码来源:index.ts


示例3: minimist

#!/usr/bin/env node

import bluebird from 'bluebird';
import fs from 'fs';
import jubatus from 'jubatus';
import _ from 'lodash';
import minimist from 'minimist';
import path from 'path';
import util from 'util';

const debug = util.debuglog('jubatus-tutorial-node');
const { common: { types: { Datum } }, classifier: { types: { LabeledDatum }, client: { Classifier } } } = jubatus;

const args = minimist(process.argv.slice(2), { default: { p: 9199, h: 'localhost', n: '', t: 0, c: 10 } });
debug('%o', args);

const { p: port, h: host, n: name, t: timeout, c: concurrency } = args;
const classifier = new Classifier(port, host, name, timeout);

const readFile = bluebird.promisify(fs.readFile);
const readDir = bluebird.promisify(fs.readdir);
const find = (dirname: string) => readDir(dirname).then(files => files.map(file => path.join(dirname, file)));
const mapStat = (file: string, iteratee: (stat: fs.Stats, file: string) => string | any) =>
    new Promise<string>((resolve, reject) => fs.stat(file, (error, stat) => error ? reject(error) : resolve(iteratee(stat, file))));
const filterStat = (files: string[], predicate: (stat: fs.Stats) => boolean) =>
    // tslint:disable-next-line:no-shadowed-variable
    Promise.all(files.map(file => mapStat(file, stat => predicate(stat) && file))).then(files => files.filter(file => file));
const list = (dirname: string) => {
    return find(dirname)
        .then(files => filterStat(files, stat => stat.isDirectory()))
        .then(directories => Promise.all(directories.map(directory => find(directory))))
开发者ID:naokikimura,项目名称:jubatus-tutorial-node,代码行数:31,代码来源:tutorial.ts


示例4: getOption

  export function getOption(name: string): string {
    if (configData) {
      return configData[name] || Private.getBodyData(name);
    }
    configData = Object.create(null);
    let found = false;

    // Use script tag if available.
    if (typeof document !== 'undefined') {
      const el = document.getElementById('jupyter-config-data');

      if (el) {
        configData = JSON.parse(el.textContent || '') as {
          [key: string]: string;
        };
        found = true;
      }
    }
    // Otherwise use CLI if given.
    if (!found && typeof process !== 'undefined') {
      try {
        const cli = minimist(process.argv.slice(2));
        const path: any = require('path');
        let fullPath = '';
        if ('jupyter-config-data' in cli) {
          fullPath = path.resolve(cli['jupyter-config-data']);
        } else if ('JUPYTER_CONFIG_DATA' in process.env) {
          fullPath = path.resolve(process.env['JUPYTER_CONFIG_DATA']);
        }
        if (fullPath) {
          /* tslint:disable */
          // Force Webpack to ignore this require.
          configData = eval('require')(fullPath) as { [key: string]: string };
          /* tslint:enable */
        }
      } catch (e) {
        console.error(e);
      }
    }

    if (!JSONExt.isObject(configData)) {
      configData = Object.create(null);
    } else {
      for (let key in configData) {
        // Quote characters are escaped, unescape them.
        configData[key] = String(configData[key])
          .split('&#39;')
          .join('"');
      }
    }
    return configData![name] || Private.getBodyData(name);
  }
开发者ID:alexmorley,项目名称:jupyterlab,代码行数:52,代码来源:pageconfig.ts


示例5: Bundler

export async function main(args: string[]): Promise<number> {
  const parsedArgs: {srcs: string, output: string, entry: string} = minimist(args);
  const inputFiles = parsedArgs.srcs.split(',');

  return new Bundler().Bundle(join(workspaceRoot, parsedArgs.entry), inputFiles).then(result => {
    writeFileSync(parsedArgs.output, result.bundledContent);
    return 0;
  }).catch(error => {
    console.error('Sass bundling failed');
    console.dir(error);
    return 1;
  });
}
开发者ID:Nodarii,项目名称:material2,代码行数:13,代码来源:sass_bundle.ts


示例6: minimist

            .then(() => {
                let args = minimist(environment.args);

                let RegisteredCommand = findCommand(
                    environment.commands,
                    args._[0]
                );

                let command = new RegisteredCommand({
                    ui: this.ui,
                    project: this.project,
                });

                return command.validateAndRun(environment.args);
            })
开发者ID:Platypi,项目名称:platypi-cli,代码行数:15,代码来源:cli.ts


示例7: parseCliArgs

export function parseCliArgs(argv: string[]): CliArgTypes {
  // remove optional unix node call
  if (path.basename(argv[0] || '') === 'node') {
    argv.splice(0, 1)
  }

  // remove optional windows node call
  if (path.win32.basename(argv[0] || '') === 'node.exe') {
    argv.splice(0, 1)
  }

  // remove optional linux text-run call
  if (path.basename(argv[0] || '') === 'text-run') {
    argv.splice(0, 1)
  }

  // remove optional Windows CLI call
  if (argv[0] && argv[0].endsWith('dist\\cli\\cli.js')) {
    argv.splice(0, 1)
  }

  const result = minimist(argv, { boolean: 'offline' })
  const commands = result._ || []
  delete result._

  // extract command
  let command = ''
  if (availableCommands().includes(commands[0])) {
    command = commands[0]
    commands.splice(0, 1)
  } else {
    command = 'run'
  }
  result.command = command
  result.files = commands[0]

  return result
}
开发者ID:Originate,项目名称:tutorial-runner,代码行数:38,代码来源:parse-cli-args.ts


示例8: generate

                  var nameParts = schemaInput.properties[propertyName].items.id.split(".");
                  var typeName = nameParts[nameParts.length - 1];
                  propertiesString = propertiesString+ "\n  {propertyName}:{typeName}[];".format({ propertyName: propertyName,typeName:typeName });
              
                  generate(output, typeName , schemaInput.properties[propertyName].items);
              }
          }
          
      }
      output[name] = "\n\nexport interface {className} {{properties}\n}".format({ className: name, properties:propertiesString });
  }
}

var args = {};
if (sys.args != undefined)
{
    args= minimist(sys.args, {});
}
var targetFileFullName = args.targetFileFullName;
if (targetFileFullName == null) {
    targetFileFullName=path.resolve(__dirname, "out.d.ts");
}
var output = {};
generate(output, "Environment", schema);
var fileOptions = { encoding: 'utf-8' };
fs.writeFileSync(targetFileFullName, "//auto-generated", fileOptions);
for (var propertyName in output) {
    fs.appendFileSync(targetFileFullName, output[propertyName], fileOptions);
}

开发者ID:kahgeh,项目名称:prototypes,代码行数:29,代码来源:app.ts


示例9: Error



import minimist from 'minimist';
import _ from 'lodash';
import fs from 'fs';
import sax from 'sax';
import { buildSite } from '../../tests/e2e/utils/site-builder';
import c from '../../tests/e2e/test-constants';
const strict = true; // set to false for html-mode
const parser = sax.parser(strict, {});

const UnknownUserId = -2; // ??
const DefaultCategoryId = 2;


const args: any = minimist(process.argv.slice(2));

const wordpressXmlFilePath: string | undefined = args.wordpressCoreXmlExportFile;
if (!_.isString(wordpressXmlFilePath))
  throw Error("Missing: --wordpressCoreXmlExportFile=...");

const writeToPath: string | undefined = args.writeTo;
if (!_.isString(writeToPath))
  throw Error("Missing: --writeTo=...");

const fileText = fs.readFileSync(wordpressXmlFilePath, { encoding: 'utf8' });

const verboseStr: string | undefined = args.verbose || args.v;
const verbose: boolean = !!verboseStr && verboseStr !== 'f' && verboseStr !== 'false';

console.log("The input file starts with: " + fileText.substring(0, 200));
开发者ID:,项目名称:,代码行数:29,代码来源:


示例10: require

  , heartbeat = require('./heartbeat')
  , shelljs = require('shelljs');

/// <reference path="./definitions/Q.d.ts" />

import Q = require('q');
import cm = require('./common');
import cfgm = require('./configuration');
import ifm = require('./api/interfaces');

var SVC_FILE_NAME = '.service';
var _cfgPath = path.join(__dirname, '..', SVC_FILE_NAME);

// on OSX (Darwin), a launchd daemon will get installed as: com.sample.myserver
// on Linux, a start-stop-daemon will get installed as: myserver
var args = argparser(process.argv.slice(2));
var action = args['_'][0];
console.log('action: ' + action);
var showUsage = function (code) {
    console.log('usage: svc.sh install, start, stop, restart');
    console.log('\taction=install, start, stop');
    console.log('\tnote: only install needs username and password');
    process.exit(code);
};
if (!action || action === '-?') {
    showUsage(action ? 0 : 1);
}
if (!cfgm.exists()) {
    console.error('The agent must be configured before running as a service. Run the agent and configure.');
    process.exit(1);
}
开发者ID:itsananderson,项目名称:vso-agent,代码行数:31,代码来源:service.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript minpubsub.publish函数代码示例发布时间:2022-05-25
下一篇:
TypeScript minimatch.Minimatch类代码示例发布时间: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