本文整理匯總了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']){