Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,14 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
if (opts.stripInternal) {
options += " --stripInternal";
}

options += " --target es5 --lib es5,scripthost --noUnusedLocals --noUnusedParameters";
options += " --target es5";
if (opts.lib) {
options += " --lib " + opts.lib
}
else {
options += " --lib es5,scripthost"
}
options += " --noUnusedLocals --noUnusedParameters";

var cmd = host + " " + compilerPath + " " + options + " ";
cmd = cmd + sources.join(" ");
Expand Down Expand Up @@ -405,7 +411,7 @@ compileFile(buildProtocolJs,
[buildProtocolTs],
[],
/*useBuiltCompiler*/ false,
{noOutFile: true});
{ noOutFile: true, lib: "es6" });

file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() {

Expand Down Expand Up @@ -567,16 +573,16 @@ compileFile(
file(typescriptServicesDts, [servicesFile]);

var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true });
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" });

var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js");
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" });

var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js");
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: false });
compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" });

var serverFile = path.join(builtLocalDirectory, "tsserver.js");
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true });
compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" });
var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts");
compileFile(
Expand Down Expand Up @@ -700,7 +706,7 @@ compileFile(
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
/*prefixes*/[],
/*useBuiltCompiler:*/ true,
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" });

var internalTests = "internal/";

Expand Down Expand Up @@ -1077,7 +1083,7 @@ desc("Compiles tslint rules to js");
task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"]));
tslintRulesFiles.forEach(function (ruleFile, i) {
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") });
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" });
});

desc("Emit the start of the build-rules fold");
Expand Down
3 changes: 2 additions & 1 deletion scripts/parallel-lint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var tslint = require("tslint");
var fs = require("fs");
var path = require("path");

function getLinterOptions() {
return {
Expand All @@ -9,7 +10,7 @@ function getLinterOptions() {
};
}
function getLinterConfiguration() {
return require("../tslint.json");
return tslint.Configuration.loadConfigurationFromPath(path.join(__dirname, "../tslint.json"));
}

function lintFileContents(options, configuration, path, contents) {
Expand Down
4 changes: 4 additions & 0 deletions src/harness/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"declaration": false,
"types": [
"node", "mocha", "chai"
],
"lib": [
"es6",
"scripthost"
]
},
"files": [
Expand Down
1 change: 0 additions & 1 deletion src/server/builder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="..\compiler\commandLineParser.ts" />
/// <reference path="..\services\services.ts" />
/// <reference path="session.ts" />
/// <reference types="node" />

namespace ts.server {

Expand Down
3 changes: 3 additions & 0 deletions src/server/cancellationToken/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"module": "commonjs",
"types": [
"node"
],
"lib": [
"es6"
]
},
"files": [
Expand Down
65 changes: 38 additions & 27 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ namespace ts.server {
constructor(private readonly logFilename: string,
private readonly traceToConsole: boolean,
private readonly level: LogLevel) {
if (this.logFilename) {
try {
this.fd = fs.openSync(this.logFilename, "w");
}
catch (e) {
// swallow the error and keep logging disabled if file cannot be opened
}
}
}

static padStringRight(str: string, padding: string) {
Expand Down Expand Up @@ -175,11 +183,6 @@ namespace ts.server {
}

msg(s: string, type: Msg.Types = Msg.Err) {
if (this.fd < 0) {
if (this.logFilename) {
this.fd = fs.openSync(this.logFilename, "w");
}
}
if (this.fd >= 0 || this.traceToConsole) {
s = s + "\n";
const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
Expand Down Expand Up @@ -410,6 +413,9 @@ namespace ts.server {
}

function parseLoggingEnvironmentString(logEnvStr: string): LogOptions {
if (!logEnvStr) {
return {};
}
const logEnv: LogOptions = { logToFile: true };
const args = logEnvStr.split(" ");
const len = args.length - 1;
Expand All @@ -422,8 +428,8 @@ namespace ts.server {
logEnv.file = stripQuotes(value);
break;
case "-level":
const level: LogLevel = (<any>LogLevel)[value];
logEnv.detailLevel = typeof level === "number" ? level : LogLevel.normal;
const level = getLogLevel(value);
logEnv.detailLevel = level !== undefined ? level : LogLevel.normal;
break;
case "-traceToConsole":
logEnv.traceToConsole = value.toLowerCase() === "true";
Expand All @@ -437,28 +443,32 @@ namespace ts.server {
return logEnv;
}

// TSS_LOG "{ level: "normal | verbose | terse", file?: string}"
function createLoggerFromEnv() {
let fileName: string = undefined;
let detailLevel = LogLevel.normal;
let traceToConsole = false;
const logEnvStr = process.env["TSS_LOG"];
if (logEnvStr) {
const logEnv = parseLoggingEnvironmentString(logEnvStr);
if (logEnv.logToFile) {
if (logEnv.file) {
fileName = logEnv.file;
}
else {
fileName = __dirname + "/.log" + process.pid.toString();
function getLogLevel(level: string) {
if (level) {
const l = level.toLowerCase();
for (const name in LogLevel) {
if (isNaN(+name) && l === name.toLowerCase()) {
return <LogLevel><any>LogLevel[name];
}
}
if (logEnv.detailLevel) {
detailLevel = logEnv.detailLevel;
}
traceToConsole = logEnv.traceToConsole;
}
return new Logger(fileName, traceToConsole, detailLevel);
return undefined;
}

// TSS_LOG "{ level: "normal | verbose | terse", file?: string}"
function createLogger() {
const cmdLineLogFileName = findArgument("--logFile");
const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity"));
const envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]);

const logFileName = cmdLineLogFileName
? stripQuotes(cmdLineLogFileName)
: envLogOptions.logToFile
? envLogOptions.file || (__dirname + "/.log" + process.pid.toString())
: undefined;

const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity)
}
// This places log file in the directory containing editorServices.js
// TODO: check that this location is writable
Expand Down Expand Up @@ -555,7 +565,6 @@ namespace ts.server {
// to increase the chunk size or decrease the interval
// time dynamically to match the large reference set?
const pollingWatchedFileSet = createPollingWatchedFileSet();
const logger = createLoggerFromEnv();

const pending: Buffer[] = [];
let canWrite = true;
Expand Down Expand Up @@ -607,6 +616,8 @@ namespace ts.server {
return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash;
}

const logger = createLogger();

const sys = <ServerHost>ts.sys;
// use watchGuard process on Windows when node version is 4 or later
const useWatchGuard = process.platform === "win32" && getNodeMajorVersion() >= 4;
Expand Down
3 changes: 2 additions & 1 deletion src/server/tsconfig.library.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true,
"declaration": true
"declaration": true,
"types": []
},
"files": [
"editorServices.ts",
Expand Down
10 changes: 8 additions & 2 deletions src/server/typingsInstaller/nodeTypingsInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ namespace ts.server.typingsInstaller {
} = require("path");

class FileLog implements Log {
private logEnabled = true;
constructor(private readonly logFile?: string) {
}

isEnabled() {
return this.logFile !== undefined;
return this.logEnabled && this.logFile !== undefined;
}
writeLine(text: string) {
fs.appendFileSync(this.logFile, text + sys.newLine);
try {
fs.appendFileSync(this.logFile, text + sys.newLine);
}
catch (e) {
this.logEnabled = false;
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/server/typingsInstaller/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"outFile": "../../../built/local/typingsInstaller.js",
"types": [
"node"
],
"lib": [
"es6",
"scripthost"
]
},
"files": [
Expand Down
10 changes: 8 additions & 2 deletions src/server/watchGuard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"extends": "../../tsconfig-base",
"extends": "../../tsconfig-base",
"compilerOptions": {
"removeComments": true,
"outFile": "../../../built/local/watchGuard.js"
"outFile": "../../../built/local/watchGuard.js",
"types": [
"node"
],
"lib": [
"es6"
]
},
"files": [
"watchGuard.ts"
Expand Down