當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript nconf.argv函數代碼示例

本文整理匯總了TypeScript中nconf.argv函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript argv函數的具體用法?TypeScript argv怎麽用?TypeScript argv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了argv函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: run

async function run() {
    // Load configuration
    nconf.argv()
        .env({ separator: "_" })
        .file("user", { file: process.env.SMU_CONFIG || "/etc/smu.yml", format: nconfYaml })
        .file("defaults", { file: join(__dirname, "../conf/defaults.yml"), format: nconfYaml });

    const config = nconf.get(null);

    // Initialize Hapi
    const server = promisify(new hapi.Server());
    server.connection(config.server);

    // init server
    try {
        await server.register(plugins);
        setupAuthentication(server, config.authentication);
        setupCommands(server, config.commands);
        await server.start();
    } catch (err) {
        server.log(["error"], "Error starting server: " + err);
        process.exit(1);
    }
    server.log(["info"], `Server running at: ${server.info.uri}`);
}
開發者ID:msurdi,項目名稱:smu,代碼行數:25,代碼來源:index.ts

示例2: load

    @InitPhase
    @ReturnsService('config')
    load() {
        nconf
          .argv()
          .env()
          .file({ file: 'config/config.json' })
          .file({ file: 'config/local.json' });

        return nconf;
    }
開發者ID:HallM,項目名稱:poc-fw2,代碼行數:11,代碼來源:index.ts

示例3: Run

function Run(): void {
    // #1 Command-line arguments
    nconf.argv();
    // #2 Environment variables
    nconf.env();
    // #3 A file located at '{.}config.json'
    nconf.file({
        file: "./config.json"
    });
    // #4 Defaults
    // default name for Azure Store Table
    nconf.defaults({
        "Azure:Store:TableName": "table-name"
    });
    console.log(JSON.stringify(nconf.get(null), null, "\t"));
}
開發者ID:samelamin,項目名稱:azure-nodejs-examples,代碼行數:16,代碼來源:index.ts

示例4: constructor

  constructor() {
    nconf
      .argv()
      .env({
        separator: '__'
      });

    nconf.defaults({
      'NODE_ENV': 'development'
    });

    const environment = nconf.get('NODE_ENV');
    const configDir = path.join(__dirname, '..', '..', '..', '..', 'config');

    nconf.file(environment, path.join(configDir, `${environment}.json`));
    nconf.file('default', path.join(configDir, 'default.json'));
  }
開發者ID:vmlf01,項目名稱:ts-painters-node,代碼行數:17,代碼來源:Config.ts

示例5: require

import * as assert from 'assert';
import * as path from 'path'

import * as engine from "../Engine"
import * as providers from "../Providers"

import { TicketState } from '../Models/ticketState';
import { ItemType } from '../Models/itemType';
import { ArtifactDownloadTicket } from '../Models/artifactDownloadTicket';

var nconf = require('nconf');

nconf.argv()
    .env()
    .file(__dirname + '/../test.config.json');

describe('Perf Tests', () => {
    describe('fileshare perf tests', () => {
        var runWindowsBasedTest = process.platform == 'win32' ? it : it.skip;
        //Artifact details => Source: FileShare, FilesCount: 301, TotalFileSize: 1.7GB
        runWindowsBasedTest('should be able to download large size build artifact from fileshare', function (done) {
            this.timeout(900000);   //15mins
            let processor = new engine.ArtifactEngine();

            let processorOptions = new engine.ArtifactEngineOptions();
            processorOptions.itemPattern = "**";
            processorOptions.parallelProcessingLimit = 64;
            processorOptions.retryIntervalInSeconds = 2;
            processorOptions.retryLimit = 4;
            processorOptions.verbose = true;
開發者ID:Microsoft,項目名稱:vsts-rm-extensions,代碼行數:30,代碼來源:fileshare.perf.ts

示例6: require

const bodyParser = require('body-parser');
const helmet = require('helmet');
const morgan = require('morgan'); // HTTP request Logger middleware for node.js
const winston = require('winston'); // Logger
const localization = require('i18n');
const path = require('path');
const nunjucks = require('nunjucks');
const cookieParser = require('cookie-parser');
const favicon = require('serve-favicon');
const nconf = require('nconf');

// Setup nconf to use (in-order):
//   1. Command-line arguments
//   2. Environment variables
//   3. A file located at './config.json'
nconf.argv().env().file({ file: './config.json' });
nconf.defaults({
  'NODE_ENV': 'development',
  'NODE_PATH': '.',
  'PORT': 3000,

  // custom flags
  'appName': 'NodeExample',
  'logLevel': 'warn',
  'logInJson': false,
  'lang': 'en-US'
});

// Environment variables
const ROOT: string = nconf.get('NODE_PATH');
const ENV: string = nconf.get('NODE_ENV');
開發者ID:melxx001,項目名稱:simple-nodejs-typescript-starter,代碼行數:31,代碼來源:server.ts

示例7: Promise

import * as fs from "fs";
import * as nconf from "nconf";
import {defaults} from "./defaults";
import * as configs from "./env";

/**
 * Create app configuration
 */
export var config = {
    // environment specific options
    for: (env) => {
        env = env.toLowerCase().trim();
        return new Promise((resolve, reject) => {
            nconf.overrides(configs[env]);             
            // do some async stuff if needed           
            resolve();
        });
    },
    // not chengable options
    get configure() {
        nconf.argv().env();
        nconf.defaults(defaults);
        nconf.file("app", {
            file: 'config.json',
            dir: __dirname,
            search: true
        });
        return this;
    }
};  
開發者ID:cm0s,項目名稱:mea2n,代碼行數:30,代碼來源:config.ts

示例8: require

import * as Discover from "./discover";

var program = require('commander');
var nconf = require('nconf');

program
  .version('0.0.1')
  .option('--acceptor_name [name]', 'Acceptor name',names.generateName().substr(0, 15))
  .option('--leader_name [name]', 'Leader name', names.generateName().substr(0, 15))
  .option('--replica_name [name]', 'replica_name', names.generateName().substr(0, 15))
  .option('--conf [configuration]', 'configuration file')
  .parse(process.argv);


if(program['conf'])
  nconf.argv().env().file({file: program['conf']});
else{
  nconf.argv()
       .env()
       .file({ file: '/etc/icarus/icarus.conf'})
       .file({ file: './conf/icarus.conf' })
}

function capitalize(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}

function createDiscover(type:string, name:string, rol:any){
  let roles = {}
  roles[process.env.rol[0].toUpperCase()] = []
  for (let ports in rol['ports']){
開發者ID:Villaz,項目名稱:Icarus,代碼行數:31,代碼來源:app.ts


注:本文中的nconf.argv函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。