forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
71 lines (60 loc) · 2.57 KB
/
server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {
Debug,
getNodeMajorVersion,
setStackTraceLimit,
sys,
version,
} from "./_namespaces/ts";
import {
emptyArray,
findArgument,
hasArgument,
initializeNodeSystem,
Msg,
StartInput,
} from "./_namespaces/ts.server";
export * from "./_namespaces/ts";
function findArgumentStringArray(argName: string): readonly string[] {
const arg = findArgument(argName);
if (arg === undefined) {
return emptyArray;
}
return arg.split(",").filter(name => name !== "");
}
function start({ args, logger, cancellationToken, serverMode, unknownServerMode, startSession: startServer }: StartInput, platform: string) {
logger.info(`Starting TS Server`);
logger.info(`Version: ${version}`);
logger.info(`Arguments: ${args.join(" ")}`);
logger.info(`Platform: ${platform} NodeVersion: ${getNodeMajorVersion()} CaseSensitive: ${sys.useCaseSensitiveFileNames}`);
logger.info(`ServerMode: ${serverMode} hasUnknownServerMode: ${unknownServerMode}`);
setStackTraceLimit();
if (Debug.isDebugging) {
Debug.enableDebugInfo();
}
if (sys.tryEnableSourceMapsForHost && /^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"))) {
sys.tryEnableSourceMapsForHost();
}
// Overwrites the current console messages to instead write to
// the log. This is so that language service plugins which use
// console.log don't break the message passing between tsserver
// and the client
console.log = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Info);
console.warn = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err);
console.error = (...args) => logger.msg(args.length === 1 ? args[0] : args.join(", "), Msg.Err);
startServer(
{
globalPlugins: findArgumentStringArray("--globalPlugins"),
pluginProbeLocations: findArgumentStringArray("--pluginProbeLocations"),
allowLocalPluginLoads: hasArgument("--allowLocalPluginLoads"),
useSingleInferredProject: hasArgument("--useSingleInferredProject"),
useInferredProjectPerProjectRoot: hasArgument("--useInferredProjectPerProjectRoot"),
suppressDiagnosticEvents: hasArgument("--suppressDiagnosticEvents"),
noGetErrOnBackgroundUpdate: hasArgument("--noGetErrOnBackgroundUpdate"),
serverMode
},
logger,
cancellationToken
);
}
setStackTraceLimit();
start(initializeNodeSystem(), require("os").platform());