Skip to content

Commit 68a00fa

Browse files
Enable proxy using for http requests
Add config.json file inside new config directory. This file is required in order to allow user specific configurations. Modify nativescript-cli.ts in order to wrap resolving of config and errors inside fiber as the new implementation of config has .wait(). Update common lib, where the following changes are applied: Rename the following config options: - FIDDLER_HOSTNAME to PROXY_HOSTNAME - PROXY_TO_FIDDLER to USE_PROXY Add PROXY_PORT option to config with default value 8888. Add ConfigBase class which should be used as a base for CLI specific configs. Required for #297 and #302
1 parent 94f3dcf commit 68a00fa

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

config/config.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"DEBUG": false,
3+
"USE_PROXY": false,
4+
"PROXY_PORT": 8888,
5+
"PROXY_HOSTNAME": "127.0.0.1",
6+
"TYPESCRIPT_COMPILER_OPTIONS": {},
7+
"CI_LOGGER": false
8+
}

lib/config.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
import path = require("path");
55
import util = require("util");
66
import staticConfigBaseLibPath = require("./common/static-config-base");
7+
import configBaseLib = require("./common/config-base");
78

8-
$injector.register("config", {
9-
CI_LOGGER: false,
10-
DEBUG: process.env.NATIVESCRIPT_DEBUG,
11-
TYPESCRIPT_COMPILER_OPTIONS: { }
12-
});
9+
export class Configuration extends configBaseLib.ConfigBase { // User specific config
10+
CI_LOGGER = false;
11+
DEBUG = process.env.NATIVESCRIPT_DEBUG;
12+
TYPESCRIPT_COMPILER_OPTIONS = {};
13+
USE_PROXY = false;
14+
15+
/*don't require logger and everything that has logger as dependency in config.js due to cyclic dependency*/
16+
constructor(protected $fs: IFileSystem) {
17+
super($fs);
18+
_.extend(this, this.loadConfig("config").wait());
19+
}
20+
}
21+
$injector.register("config", Configuration);
1322

1423
export class StaticConfig extends staticConfigBaseLibPath.StaticConfigBase implements IStaticConfig {
1524
public PROJECT_FILE_NAME = ".tnsproject";

lib/nativescript-cli.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import Future = require("fibers/future");
88
import errors = require("./common/errors");
99
errors.installUncaughtExceptionListener();
1010

11-
var config = <Config.IConfig>$injector.resolve("$config");
12-
(<IErrors>$injector.resolve("$errors")).printCallStack = config.DEBUG;
13-
1411
fiber(() => {
15-
var commandDispatcher : ICommandDispatcher = $injector.resolve("commandDispatcher");
12+
var config = <Config.IConfig>$injector.resolve("$config");
13+
var err = <IErrors>$injector.resolve("$errors");
14+
err.printCallStack = config.DEBUG;
15+
16+
var commandDispatcher: ICommandDispatcher = $injector.resolve("commandDispatcher");
1617

1718
if (process.argv[2] === "completion") {
1819
commandDispatcher.completeCommand().wait();

0 commit comments

Comments
 (0)