Skip to content

Commit

Permalink
Refactor: maxcso-js backports (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Jul 26, 2024
1 parent 70588c2 commit 71bea04
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
}
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

## Supported platforms

| OS | Architectures | Additional Instructions |
|------------------------|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Windows](./bin/win32) | • x64<br>• x86 | |
| [macOS](./bin/darwin) | • arm64 (Apple Silicon)<br>• x64 (Intel) | [SDL2](https://www.libsdl.org/) is required to be installed separately:<br><pre>brew install sdl2</pre> |
| [Linux](./bin/linux) | • x64<br>• x86<br>• arm (armhf)<br>• arm64 (aarch64) | [SDL2](https://www.libsdl.org/) is required to be installed separately:<ul><li>Debian: `apt-get install libsdl2-2.0-0`</li><li>Gentoo: `emerge libsdl2`</li><li>Red Hat: `dnf install SDL2`</li></ul> |

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) | <ul><li>x64</li><li>x86</li></ul> | |
| [macOS](./bin/darwin) | <ul><li>arm64 (Apple Silicon)</li><li>x64 (Intel)</li></ul> | [SDL2](https://www.libsdl.org/) is required to be installed separately:</li><pre>brew install sdl2</pre> |
| [Linux](./bin/linux) | <ul><li>x64</li><li>x86</li><li>arm (armhf)</li><li>arm64 (aarch64)</li></ul> | [SDL2](https://www.libsdl.org/) is required to be installed separately:<ul><li>Debian: `apt-get install libsdl2-2.0-0`</li><li>Gentoo: `emerge libsdl2`</li><li>Red Hat: `dnf install SDL2`</li></ul> |

## Running

Expand Down Expand Up @@ -91,3 +89,7 @@ await chdman.extractDvd({
outputFilename: 'Extracted.iso',
});
```

## License

MAME and its tools are licensed under the GPLv2 license.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "💿 chdman binaries and wrapper for Node.js.",
"keywords": [
"chdman",
"isos",
"mame",
"roms"
],
Expand Down
5 changes: 4 additions & 1 deletion src/chdman/chdmanBin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}
}
6 changes: 3 additions & 3 deletions test/chdman/chdmanCd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
6 changes: 3 additions & 3 deletions test/chdman/chdmanDvd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
6 changes: 3 additions & 3 deletions test/chdman/chdmanHd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down
6 changes: 3 additions & 3 deletions test/chdman/chdmanRaw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down

0 comments on commit 71bea04

Please sign in to comment.