Skip to content

Commit

Permalink
Remove dead code detected by knip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaltby committed Oct 25, 2024
1 parent ca57e02 commit 7365f75
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 328 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,20 @@
"gb-studio-cli": "./out/cli/gb-studio-cli.js"
},
"dependencies": {
"3x3-equation-solver": "^1.2.18",
"@octokit/rest": "^16.25.4",
"@reduxjs/toolkit": "^2.2.7",
"@sinclair/typebox": "^0.32.35",
"@types/classnames": "^2.2.10",
"@types/node-gzip": "^1.1.0",
"@types/pngjs": "^6.0.0",
"@types/prismjs": "^1.26.0",
"@types/react-select": "^5.0.1",
"@types/react-window": "^1.8.8",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"3x3-equation-solver": "^1.2.18",
"about-window": "^1.15.2",
"adm-zip": "^0.5.16",
"chokidar": "^3.6.0",
"chroma-js": "^2.4.2",
"classnames": "^2.2.5",
"commander": "^6.2.0",
"copy-webpack-plugin": "^9.0.0",
"deepmerge": "^3.1.0",
Expand Down
31 changes: 0 additions & 31 deletions src/components/ui/buttons/CopyButton.tsx

This file was deleted.

25 changes: 0 additions & 25 deletions src/components/ui/buttons/ListItemButton.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions src/components/ui/form/SelectField.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions src/components/ui/hooks/use-delayed-state.ts

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/ui/hooks/use-sorted.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/components/ui/lists/CollapsibleRow.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/lib/compiler/makeBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ export const cancelBuildCommandsInProgress = async () => {
// Kill all spawned commands and any commands that were spawned by those
// e.g lcc spawns sdcc, etc.
for (const child of childSet) {
if (child.pid === undefined) {
continue;
}
const spawnedChildren = await psTreeAsync(child.pid);
for (const childChild of spawnedChildren) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/cli/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const spawn = (

child.on("close", async (childCode) => {
complete = true;
code = childCode;
code = childCode ?? 0;
});

return {
Expand Down
21 changes: 12 additions & 9 deletions src/lib/helpers/fs/writeFileAndFlush.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { open, writeFile, close, fdatasync } from "fs";
import { open, writeFile, close, fdatasync, WriteFileOptions } from "fs";

export interface WriteFileAndFlushOptions {
encoding: string;
encoding: BufferEncoding;
mode: string | number | null | undefined;
flag: string;
}

export const writeFileAndFlush = (
path: string,
data: unknown,
options: WriteFileAndFlushOptions | string,
data: string | NodeJS.ArrayBufferView,
options: WriteFileAndFlushOptions | BufferEncoding,
callback: (err?: NodeJS.ErrnoException | null) => void
) => {
// If options passed in as a string convert to WriteFileAndFlushOptions
const writeOptions =
const writeOptions: WriteFileOptions =
typeof options === "string"
? { encoding: options, mode: 0o666, flag: "w" }
: options;
: {
...options,
mode: options.mode ?? 0o666,
};

// Open the file with same flags and mode as fs.writeFile()
open(path, writeOptions.flag, writeOptions.mode, (openError, fd) => {
Expand All @@ -25,7 +28,7 @@ export const writeFileAndFlush = (
}

// It is valid to pass a fd handle to fs.writeFile() and this will keep the handle open!
return writeFile(fd, data, writeOptions.encoding, (writeError) => {
return writeFile(fd, data, writeOptions, (writeError) => {
if (writeError) {
return close(fd, () => callback(writeError)); // still need to close the handle on error!
}
Expand All @@ -40,8 +43,8 @@ export const writeFileAndFlush = (

export const writeFileAndFlushAsync = (
path: string,
data: unknown,
options: WriteFileAndFlushOptions | string = "utf8"
data: string | NodeJS.ArrayBufferView,
options: WriteFileAndFlushOptions | BufferEncoding = "utf8"
) => {
return new Promise<void>((resolve, reject) => {
writeFileAndFlush(path, data, options, (err) => {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/helpers/fs/writeFileWithBackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const backupFile = (

export const writeFileWithBackup = (
path: string,
data: unknown,
options: WriteFileAndFlushOptions | string,
data: string | NodeJS.ArrayBufferView,
options: WriteFileAndFlushOptions | BufferEncoding,
callback: (err?: NodeJS.ErrnoException | unknown | null) => void
) => {
return backupFile(path, (backupError) => {
Expand Down Expand Up @@ -50,8 +50,8 @@ export const writeFileWithBackup = (

export const writeFileWithBackupAsync = (
path: string,
data: unknown,
options: WriteFileAndFlushOptions | string = "utf8"
data: string | NodeJS.ArrayBufferView,
options: WriteFileAndFlushOptions | BufferEncoding = "utf8"
) => {
return new Promise<void>((resolve, reject) => {
writeFileWithBackup(path, data, options, (err) => {
Expand Down
Loading

0 comments on commit 7365f75

Please sign in to comment.