@@ -83,7 +83,7 @@ class LeetCodeManager extends EventEmitter {
|
83 | 83 | env: createEnvOption(),
|
84 | 84 | });
|
85 | 85 |
|
86 |
| -childProc.stdout.on("data", async (data: string | Buffer) => { |
| 86 | +childProc.stdout?.on("data", async (data: string | Buffer) => { |
87 | 87 | data = data.toString();
|
88 | 88 | leetCodeChannel.append(data);
|
89 | 89 | if (data.includes("twoFactorCode")) {
|
@@ -96,19 +96,19 @@ class LeetCodeManager extends EventEmitter {
|
96 | 96 | childProc.kill();
|
97 | 97 | return resolve(undefined);
|
98 | 98 | }
|
99 |
| -childProc.stdin.write(`${twoFactor}\n`); |
| 99 | +childProc.stdin?.write(`${twoFactor}\n`); |
100 | 100 | }
|
101 | 101 | const successMatch: RegExpMatchArray | null = data.match(this.successRegex);
|
102 | 102 | if (successMatch && successMatch[1]) {
|
103 |
| -childProc.stdin.end(); |
| 103 | +childProc.stdin?.end(); |
104 | 104 | return resolve(successMatch[1]);
|
105 | 105 | } else if (data.match(this.failRegex)) {
|
106 |
| -childProc.stdin.end(); |
| 106 | +childProc.stdin?.end(); |
107 | 107 | return reject(new Error("Faile to login"));
|
108 | 108 | }
|
109 | 109 | });
|
110 | 110 |
|
111 |
| -childProc.stderr.on("data", (data: string | Buffer) => leetCodeChannel.append(data.toString())); |
| 111 | +childProc.stderr?.on("data", (data: string | Buffer) => leetCodeChannel.append(data.toString())); |
112 | 112 |
|
113 | 113 | childProc.on("error", reject);
|
114 | 114 | const name: string | undefined = await vscode.window.showInputBox({
|
@@ -120,7 +120,7 @@ class LeetCodeManager extends EventEmitter {
|
120 | 120 | childProc.kill();
|
121 | 121 | return resolve(undefined);
|
122 | 122 | }
|
123 |
| -childProc.stdin.write(`${name}\n`); |
| 123 | +childProc.stdin?.write(`${name}\n`); |
124 | 124 | const pwd: string | undefined = await vscode.window.showInputBox({
|
125 | 125 | prompt: isByCookie ? "Enter cookie" : "Enter password.",
|
126 | 126 | password: true,
|
@@ -131,7 +131,7 @@ class LeetCodeManager extends EventEmitter {
|
131 | 131 | childProc.kill();
|
132 | 132 | return resolve(undefined);
|
133 | 133 | }
|
134 |
| -childProc.stdin.write(`${pwd}\n`); |
| 134 | +childProc.stdin?.write(`${pwd}\n`); |
135 | 135 | });
|
136 | 136 | if (userName) {
|
137 | 137 | vscode.window.showInformationMessage(`Successfully ${inMessage}.`);
|
|
0 commit comments