From 71bea042cd19e01898058abe93ff2dd19d5d622b Mon Sep 17 00:00:00 2001 From: Christian Emmer <10749361+emmercm@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:25:20 -0700 Subject: [PATCH] Refactor: maxcso-js backports (#36) --- .eslintrc | 5 ++++- README.md | 16 +++++++++------- package.json | 1 + src/chdman/chdmanBin.ts | 5 ++++- test/chdman/chdmanCd.test.ts | 6 +++--- test/chdman/chdmanDvd.test.ts | 6 +++--- test/chdman/chdmanHd.test.ts | 6 +++--- test/chdman/chdmanRaw.test.ts | 6 +++--- 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4c7e662..2d95a17 100644 --- a/.eslintrc +++ b/.eslintrc @@ -95,6 +95,9 @@ "no-restricted-syntax": ["error", { "selector": "CallExpression[callee.property.name='push'] > SpreadElement", "message": "Array#push(...Array) can cause 'call stack size exceeded' runtime errors when pushing many values, prefer 'Array = [...Array, ...Array]'" - }] + }], + + // ***** Strings ***** + "unicorn/prefer-string-replace-all": ["off"] } } diff --git a/README.md b/README.md index 38eb065..35b6b32 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,11 @@ ## Supported platforms -| OS | Architectures | Additional Instructions | -|------------------------|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [Windows](./bin/win32) | • x64
• x86 | | -| [macOS](./bin/darwin) | • arm64 (Apple Silicon)
• x64 (Intel) | [SDL2](https://www.libsdl.org/) is required to be installed separately:
brew install sdl2
| -| [Linux](./bin/linux) | • x64
• x86
• arm (armhf)
• arm64 (aarch64) | [SDL2](https://www.libsdl.org/) is required to be installed separately: | - -Any `chdman` that exists on your `$PATH` will be preferred over the bundled binaries. This lets you control the build that is right for your machine. +| OS | Architectures | Additional Instructions | +|------------------------|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [Windows](./bin/win32) | | | +| [macOS](./bin/darwin) | | [SDL2](https://www.libsdl.org/) is required to be installed separately:
brew install sdl2
| +| [Linux](./bin/linux) | | [SDL2](https://www.libsdl.org/) is required to be installed separately: | ## Running @@ -91,3 +89,7 @@ await chdman.extractDvd({ outputFilename: 'Extracted.iso', }); ``` + +## License + +MAME and its tools are licensed under the GPLv2 license. diff --git a/package.json b/package.json index f7b091b..ea1e306 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "💿 chdman binaries and wrapper for Node.js.", "keywords": [ "chdman", + "isos", "mame", "roms" ], diff --git a/src/chdman/chdmanBin.ts b/src/chdman/chdmanBin.ts index 8e0b11e..0cb69ec 100644 --- a/src/chdman/chdmanBin.ts +++ b/src/chdman/chdmanBin.ts @@ -98,7 +98,10 @@ export default class ChdmanBin { } return resolve(output); }); - proc.on('error', reject); + proc.on('error', () => { + const output = Buffer.concat(chunks).toString(); + reject(output); + }); }); } } diff --git a/test/chdman/chdmanCd.test.ts b/test/chdman/chdmanCd.test.ts index 31c35cc..39e6bb6 100644 --- a/test/chdman/chdmanCd.test.ts +++ b/test/chdman/chdmanCd.test.ts @@ -16,15 +16,15 @@ it('should fail on nonexistent file', async () => { await expect(ChdmanCd.createCd({ inputFilename: os.devNull, outputFilename: temporaryChd, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanInfo.info({ inputFilename: temporaryChd, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanCd.extractCd({ inputFilename: temporaryChd, outputFilename: temporaryCue, outputBinFilename: temporaryBin, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); } finally { await util.promisify(fs.rm)(temporaryChd, { force: true }); } diff --git a/test/chdman/chdmanDvd.test.ts b/test/chdman/chdmanDvd.test.ts index 667d152..2f0aa7c 100644 --- a/test/chdman/chdmanDvd.test.ts +++ b/test/chdman/chdmanDvd.test.ts @@ -18,14 +18,14 @@ it('should fail on nonexistent file', async () => { await expect(ChdmanDvd.createDvd({ inputFilename: os.devNull, outputFilename: temporaryChd, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanInfo.info({ inputFilename: temporaryIso, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanDvd.createDvd({ inputFilename: temporaryChd, outputFilename: temporaryIso, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); } finally { await util.promisify(fs.rm)(temporaryChd, { force: true }); } diff --git a/test/chdman/chdmanHd.test.ts b/test/chdman/chdmanHd.test.ts index abcaef1..1b682f8 100644 --- a/test/chdman/chdmanHd.test.ts +++ b/test/chdman/chdmanHd.test.ts @@ -17,14 +17,14 @@ it('should fail on nonexistent file', async () => { await expect(ChdmanHd.createHd({ inputFilename: os.devNull, outputFilename: temporaryChd, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanInfo.info({ inputFilename: temporaryHd, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanHd.extractHd({ inputFilename: temporaryChd, outputFilename: temporaryHd, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); } finally { await util.promisify(fs.rm)(temporaryChd, { force: true }); } diff --git a/test/chdman/chdmanRaw.test.ts b/test/chdman/chdmanRaw.test.ts index 9fe81f4..94ae8a1 100644 --- a/test/chdman/chdmanRaw.test.ts +++ b/test/chdman/chdmanRaw.test.ts @@ -17,14 +17,14 @@ it('should fail on nonexistent file', async () => { outputFilename: temporaryChd, hunkSize: 64, unitSize: 64, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanInfo.info({ inputFilename: temporaryRaw, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); await expect(ChdmanRaw.extractRaw({ inputFilename: temporaryChd, outputFilename: temporaryRaw, - })).rejects.toBeDefined(); + })).rejects.toBeTruthy(); } finally { await util.promisify(fs.rm)(temporaryChd, { force: true }); }