本文整理汇总了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}`);
}
示例2: load
@InitPhase
@ReturnsService('config')
load() {
nconf
.argv()
.env()
.file({ file: 'config/config.json' })
.file({ file: 'config/local.json' });
return nconf;
}
示例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"));
}
示例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'));
}
示例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;
示例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');
示例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;
}
};
示例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']){