Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
pkfln committed Jan 23, 2021
1 parent 614d0b2 commit 2f33742
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build
package.json
.prettierrc
.eslintrc.json
README.md
tsconfig.json
tsconfig.release.json
6 changes: 3 additions & 3 deletions release.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const rc = {
}
return next();
},
]
],
});

// Patch CLI from showing up
Expand All @@ -64,8 +64,8 @@ const rc = {
const [PeSignature] = Array.from(bufferpack.unpack('<I', await read(PeHeaderOffset, 4)));

if (PeSignature !== 0x4550) throw new Error('File is missing PE header signature.');
await write(PeHeaderOffset + 0x5C, bufferpack.pack('<H', [0x2]));

await write(PeHeaderOffset + 0x5c, bufferpack.pack('<H', [0x2]));
await outputHandle.close();
} catch (e) {
console.error(e);
Expand Down
4 changes: 1 addition & 3 deletions src/Discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ class Discord {
}

private getServerImageKey(ip: string, port: number): string {
if (!this.serverImages.includes(`${ip}_${port}.png`))
return DEFAULT_IMAGE_KEY;

if (!this.serverImages.includes(`${ip}_${port}.png`)) return DEFAULT_IMAGE_KEY;
return `${ip.replace(/\./g, '_')}_${port}`;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Internal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Game from "./Game";
import MessageBox from "./MessageBox";
import MTAInstallation from "./MTAInstallation";
import Game from './Game';
import MessageBox from './MessageBox';
import MTAInstallation from './MTAInstallation';

export default abstract class Internal {
static async initializeApp(): Promise<void> {
Expand Down
5 changes: 2 additions & 3 deletions src/MTAInstallation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export default abstract class MTAInstallation {
try {
response = await execa('powershell.exe', [`(Get-ItemProperty -Path ${regPath}).'${regName}'`]);

if (!response.stdout)
throw Error();
if (!response.stdout) throw Error();
} catch {
throw Error('Could not find MTA installation path. (1)');
}
Expand All @@ -35,7 +34,7 @@ export default abstract class MTAInstallation {
const win32Path = path.win32.dirname(trimmedPath);

try {
await fs.access(path.win32.join(win32Path, exeName))
await fs.access(path.win32.join(win32Path, exeName));
} catch {
throw Error('Could not find MTA installation path. (2)');
}
Expand Down
11 changes: 7 additions & 4 deletions src/MTAQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ export default class MTAQuery {
const socket = Dgram.createSocket('udp4');
let packet: Promise<IncomingPacket>;

await this.timeoutPromise(1000, socket.send('s', this.port + (this.isUDPPort ? 0 : 123), this.ip), 'MTAQuery: Could not send buffer to server.');
await this.timeoutPromise(1000, packet = socket.recv(), 'MTAQuery: Did not get any response.');
await this.timeoutPromise(
1000,
socket.send('s', this.port + (this.isUDPPort ? 0 : 123), this.ip),
'MTAQuery: Could not send buffer to server.'
);
await this.timeoutPromise(1000, (packet = socket.recv()), 'MTAQuery: Did not get any response.');
await socket.close();

let response = new TextDecoder().decode((await packet).msg);
Expand All @@ -53,8 +57,7 @@ export default class MTAQuery {
const playersMax = parseInt(parsedData[8]);
const players = [];

for (let i = 9; i < 9 + (playersCount * 0x5); i += 0x5)
players.push(parsedData[i]);
for (let i = 9; i < 9 + playersCount * 0x5; i += 0x5) players.push(parsedData[i]);

return { serverName, playersCount, playersMax, players };
}
Expand Down

0 comments on commit 2f33742

Please sign in to comment.