Skip to content

Commit

Permalink
Merge pull request #14807 from minestarks/typingsafelist
Browse files Browse the repository at this point in the history
Allow specifying the location of typingSafeList.json
  • Loading branch information
minestarks authored Mar 28, 2017
2 parents 0fd0903 + f1339ec commit 711f62f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ namespace ts.server {
host: ServerHost,
eventPort: number,
readonly globalTypingsCacheLocation: string,
readonly typingSafeListLocation: string,
private newLine: string) {
this.throttledOperations = new ThrottledOperations(host);
if (eventPort) {
Expand Down Expand Up @@ -260,6 +261,9 @@ namespace ts.server {
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`));
}
if (this.typingSafeListLocation) {
args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation);
}
const execArgv: string[] = [];
{
for (const arg of process.execArgv) {
Expand Down Expand Up @@ -378,11 +382,12 @@ namespace ts.server {
useSingleInferredProject: boolean,
disableAutomaticTypingAcquisition: boolean,
globalTypingsCacheLocation: string,
typingSafeListLocation: string,
telemetryEnabled: boolean,
logger: server.Logger) {
const typingsInstaller = disableAutomaticTypingAcquisition
? undefined
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine);
: new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, host.newLine);

super(
host,
Expand Down Expand Up @@ -729,6 +734,8 @@ namespace ts.server {
validateLocaleAndSetLanguage(localeStr, sys);
}

const typingSafeListLocation = findArgument("--typingSafeListLocation");

const useSingleInferredProject = hasArgument("--useSingleInferredProject");
const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition");
const telemetryEnabled = hasArgument(Arguments.EnableTelemetry);
Expand All @@ -741,6 +748,7 @@ namespace ts.server {
useSingleInferredProject,
disableAutomaticTypingAcquisition,
getGlobalTypingsCacheLocation(),
typingSafeListLocation,
telemetryEnabled,
logger);
process.on("uncaughtException", function (err: Error) {
Expand Down
1 change: 1 addition & 0 deletions src/server/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ts.server {
export const GlobalCacheLocation = "--globalTypingsCacheLocation";
export const LogFile = "--logFile";
export const EnableTelemetry = "--enableTelemetry";
export const TypingSafeListLocation = "--typingSafeListLocation";
}

export function hasArgument(argumentName: string) {
Expand Down
7 changes: 4 additions & 3 deletions src/server/typingsInstaller/nodeTypingsInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ namespace ts.server.typingsInstaller {

private delayedInitializationError: InitializationFailedResponse;

constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) {
constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, throttleLimit: number, log: Log) {
super(
sys,
globalTypingsCacheLocation,
toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
throttleLimit,
log);
if (this.log.isEnabled()) {
Expand Down Expand Up @@ -164,6 +164,7 @@ namespace ts.server.typingsInstaller {

const logFilePath = findArgument(server.Arguments.LogFile);
const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation);
const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation);

const log = new FileLog(logFilePath);
if (log.isEnabled()) {
Expand All @@ -177,6 +178,6 @@ namespace ts.server.typingsInstaller {
}
process.exit(0);
});
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, log);
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, /*throttleLimit*/5, log);
installer.listen();
}

0 comments on commit 711f62f

Please sign in to comment.