in app/lib/tfcommand.ts [71:141]
protected initialize(): Promise<Executor<any>> {
this.initialized = this.commandArgs.help.val().then(needHelp => {
if (needHelp) {
return this.run.bind(this, this.getHelp.bind(this));
} else {
// Set the fiddler proxy
return this.commandArgs.fiddler
.val()
.then(useProxy => {
if (useProxy) {
process.env.HTTP_PROXY = "http://127.0.0.1:8888";
}
})
.then(() => {
// Set custom proxy
return this.commandArgs.proxy.val(true).then(proxy => {
if (proxy) {
process.env.HTTP_PROXY = proxy;
}
});
})
.then(() => {
// Set the no-prompt flag
return this.commandArgs.noPrompt.val(true).then(noPrompt => {
common.NO_PROMPT = noPrompt;
});
})
.then(() => {
// If --no-color specified, Patch console.log to never output color bytes
return this.commandArgs.noColor.val(true).then(noColor => {
if (noColor) {
console.log = logNoColors;
}
});
})
.then(() => {
// Set the cached service url
return this.commandArgs.serviceUrl.val(true).then(serviceUrl => {
if (!serviceUrl && !process.env["TFX_BYPASS_CACHE"] && common.EXEC_PATH.join("") !== "login") {
let diskCache = new DiskCache("tfx");
return diskCache.itemExists("cache", "connection").then(isConnection => {
let connectionUrlPromise: Promise<string>;
if (!isConnection) {
connectionUrlPromise = Promise.resolve<string>(null);
} else {
connectionUrlPromise = diskCache.getItem("cache", "connection");
}
return connectionUrlPromise.then(url => {
if (url) {
this.commandArgs.serviceUrl.setValue(url);
}
});
});
} else {
return Promise.resolve<void>(null);
}
});
})
.then(() => {
let apiPromise = Promise.resolve<any>(null);
if (this.serverCommand) {
apiPromise = this.getWebApi().then(_ => {});
}
return apiPromise.then(() => {
return this.run.bind(this, this.exec.bind(this));
});
});
}
});
return this.initialized;
}