Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
105 lines (80 loc) · 2.85 KB

File metadata and controls

105 lines (80 loc) · 2.85 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/// <reference path="..\src\compiler\sys.ts"/>
/// <reference path="..\src\compiler\types.ts"/>
module perftest {
interface IOLog {
resolvePath: ts.Map<string>;
fileNames: string[];
}
export interface IO {
getOut(): string;
}
export var readFile = ts.sys.readFile;
var writeFile = ts.sys.writeFile;
export var write = ts.sys.write;
var resolvePath = ts.sys.resolvePath;
export var getExecutingFilePath = ts.sys.getExecutingFilePath;
export var getCurrentDirectory = ts.sys.getCurrentDirectory;
var exit = ts.sys.exit;
var args = ts.sys.args;
// augment sys so first ts.executeCommandLine call will be finish silently
ts.sys.write = (s: string) => { };
ts.sys.exit = (code: number) => { };
ts.sys.args = []
export function restoreSys() {
ts.sys.args = args;
ts.sys.write = write;
}
export function hasLogIOFlag() {
return args.length > 2 && args[0] === "--logio";
}
export function getArgsWithoutLogIOFlag() {
return args.slice(2);
}
export function getArgsWithoutIOLogFile() {
return args.slice(1);
}
var resolvePathLog: ts.Map<string> = {};
export function interceptIO() {
ts.sys.resolvePath = (s) => {
var result = resolvePath(s);
resolvePathLog[s] = result;
return result;
};
}
export function writeIOLog(fileNames: string[]) {
var path = args[1];
var log: IOLog = {
fileNames: fileNames,
resolvePath: resolvePathLog
};
writeFile(path, JSON.stringify(log));
}
export function prepare(): IO {
var log = <IOLog>JSON.parse(readFile(args[0]));
var files: ts.Map<string> = {};
log.fileNames.forEach(f => { files[f] = readFile(f); })
ts.sys.createDirectory = (s: string) => { };
ts.sys.directoryExists = (s: string) => true;
ts.sys.fileExists = (s: string) => true;
var currentDirectory = ts.sys.getCurrentDirectory();
ts.sys.getCurrentDirectory = () => currentDirectory;
var executingFilePath = ts.sys.getExecutingFilePath();
ts.sys.getExecutingFilePath = () => executingFilePath;
ts.sys.readFile = (s: string) => {
return files[s];
}
ts.sys.resolvePath = (s: string) => {
var path = log.resolvePath[s];
if (!path) {
throw new Error("Unexpected path '" + s + "'");
}
return path
}
ts.sys.writeFile = (path: string, data: string) => { };
var out: string = "";
ts.sys.write = (s: string) => { out += s; };
return {
getOut: () => out,
};
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.