Skip to content

Commit 19f4b8f

Browse files
committed
fix typescript errors
1 parent e3e36c7 commit 19f4b8f

File tree

1 file changed

+8
-13
lines changed
  • packages/jest-changed-files/src

1 file changed

+8
-13
lines changed

packages/jest-changed-files/src/sl.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,17 @@ const adapter: SCMAdapter = {
5757
getRoot: async cwd => {
5858
try {
5959
const subprocess = execa('sl', ['root'], {cwd, env});
60-
if (subprocess.stdout == null) {
61-
return null;
62-
}
6360

6461
// Check if we're calling sl (steam locomotive) instead of sl (sapling)
6562
// by looking for the escape character in the first chunk of data.
66-
let firstChunk = true;
67-
subprocess.stdout.on('data', data => {
68-
if (!firstChunk) {
69-
return;
70-
}
71-
if (data.toString().codePointAt(0) === 27) {
72-
subprocess.cancel();
73-
}
74-
firstChunk = false;
75-
});
63+
if (subprocess.stdout) {
64+
subprocess.stdout.once('data', (data: Buffer | string) => {
65+
data = Buffer.isBuffer(data) ? data.toString() : data;
66+
if (data.codePointAt(0) === 27) {
67+
subprocess.cancel();
68+
}
69+
});
70+
}
7671

7772
const result = await subprocess;
7873
if (result.killed) {

0 commit comments

Comments
 (0)