当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript config.util类代码示例

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


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

示例1: convert

      Object.keys(current).forEach(name => {
        let value = current[name];

        if (typeof value === 'object' && value !== null) {
          value = convert(value);
        }

        if (typeof value === 'string') {
          if (value.indexOf('\\') === 0) {
            value = value.replace('\\', '');
          } else {
            if (process.env[value]) {
              value = process.env[value];
            } else if (value.indexOf('.') === 0 || value.indexOf('..') === 0) {
              // Make relative paths absolute
              value = path.resolve(
                path.join(config.util.getEnv('NODE_CONFIG_DIR')),
                value.replace(/\//g, separator)
              );
            }
          }
        }

        result[name] = value;
      });
开发者ID:feathersjs,项目名称:feathers,代码行数:25,代码来源:index.ts

示例2: checkActivityPubUrls

async function checkActivityPubUrls () {
  const actor = await getServerActor()

  const parsed = parse(actor.url)
  if (CONFIG.WEBSERVER.HOST !== parsed.host) {
    const NODE_ENV = config.util.getEnv('NODE_ENV')
    const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR')

    logger.warn(
      'It seems PeerTube was started (and created some data) with another domain name. ' +
      'This means you will not be able to federate! ' +
      'Please use %s %s npm run update-host to fix this.',
      NODE_CONFIG_DIR ? `NODE_CONFIG_DIR=${NODE_CONFIG_DIR}` : '',
      NODE_ENV ? `NODE_ENV=${NODE_ENV}` : ''
    )
  }
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:17,代码来源:checker.ts

示例3: getLocalConfigFilePath

function getLocalConfigFilePath () {
  const configSources = config.util.getConfigSources()
  if (configSources.length === 0) throw new Error('Invalid config source.')

  let filename = 'local'
  if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}`
  if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}`

  return join(dirname(configSources[ 0 ].name), filename + '.json')
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:10,代码来源:constants.ts

示例4: return

  return (app: Application|undefined) => {
    const convert = (current: any) => {
      const result: { [key: string]: any } = Array.isArray(current) ? [] : {};

      Object.keys(current).forEach(name => {
        let value = current[name];

        if (typeof value === 'object' && value !== null) {
          value = convert(value);
        }

        if (typeof value === 'string') {
          if (value.indexOf('\\') === 0) {
            value = value.replace('\\', '');
          } else {
            if (process.env[value]) {
              value = process.env[value];
            } else if (value.indexOf('.') === 0 || value.indexOf('..') === 0) {
              // Make relative paths absolute
              value = path.resolve(
                path.join(config.util.getEnv('NODE_CONFIG_DIR')),
                value.replace(/\//g, separator)
              );
            }
          }
        }

        result[name] = value;
      });

      return result;
    };

    const env = config.util.getEnv('NODE_ENV');
    const conf = convert(config);

    if (!app) {
      return conf;
    }

    debug(`Initializing configuration for ${env} environment`);

    Object.keys(conf).forEach(name => {
      const value = conf[name];
      debug(`Setting ${name} configuration value to`, value);
      (app as Application).set(name, value);
    });

    return conf;
  };
开发者ID:feathersjs,项目名称:feathers,代码行数:50,代码来源:index.ts

示例5:

/// <reference path="config.d.ts" />

import * as config from "config";

var class1: config.IConfig = config;

var value1: string = config.get<string>("");
var value2: any = config.get("");

var has: boolean = config.has("");

// util tests:
var extended1: any = config.util.extendDeep({}, {});
var extended2: any = config.util.extendDeep({}, {}, 20);

var clone1: any = config.util.cloneDeep({});
var clone2: any = config.util.cloneDeep({}, 20);

var equals1: boolean = config.util.equalsDeep({}, {});
var equals2: boolean = config.util.equalsDeep({}, {}, 20);

var diff1: any = config.util.diffDeep({}, {});
var diff2: any = config.util.diffDeep({}, {}, 20);

var immutable1: any = config.util.makeImmutable({});
var immutable2: any = config.util.makeImmutable({}, "");
var immutable3: any = config.util.makeImmutable({}, "", "");

var hidden1: any = config.util.makeHidden({}, "");
var hidden2: any = config.util.makeHidden({}, "", "");
开发者ID:0815fox,项目名称:DefinitelyTyped,代码行数:30,代码来源:config-tests.ts

示例6: function

import * as winston from 'winston';
import * as config from 'config';

export const logger = new winston.Logger();

const env = config.util.getEnv('NODE_ENV');

// Development Logger
if(env === 'development') {
  logger.add(winston.transports.Console, {
    type: 'verbose',
    colorize: true,
    prettyPrint: true,
    handleExceptions: true,
    humanReadableUnhandledException: true
  });
}

process.on('unhandledRejection', function (reason, p) {
  logger.warn('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
});
开发者ID:efueger,项目名称:node-microservice-demo,代码行数:21,代码来源:logging.ts

示例7:

import * as config from "config";

var class1: config.IConfig = config;

var value1: string = config.get<string>("");
var value2: any = config.get("");

var has: boolean = config.has("");

// util tests:
var extended1: any = config.util.extendDeep({}, {});
var extended2: any = config.util.extendDeep({}, {}, 20);

var clone1: any = config.util.cloneDeep({});
var clone2: any = config.util.cloneDeep({}, 20);

var equals1: boolean = config.util.equalsDeep({}, {});
var equals2: boolean = config.util.equalsDeep({}, {}, 20);

var diff1: any = config.util.diffDeep({}, {});
var diff2: any = config.util.diffDeep({}, {}, 20);

var immutable1: any = config.util.makeImmutable({});
var immutable2: any = config.util.makeImmutable({}, "");
var immutable3: any = config.util.makeImmutable({}, "", "");

var hidden1: any = config.util.makeHidden({}, "");
var hidden2: any = config.util.makeHidden({}, "", "");

var env: string = config.util.getEnv("");
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:30,代码来源:config-tests.ts


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