oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.78k stars 2.73k forks source link

Nyc does not work with Bun / `process.binding("spawn_sync")` is not implemented #8694

Open ygrandgirard opened 8 months ago

ygrandgirard commented 8 months ago

What version of Bun is running?

1.0.26

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

test('ok', () => { expect(ok()).toBe(true); });

* `package.json` :
```typescript
{
  "name": "bun-nyc",
  "module": "index.ts",
  "type": "module",
  "scripts": {
    "test": "nyc bun test"
  },
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "nyc": "^15.1.0"
  }
}

What is the expected behavior?

Run nyc, and do whatever it is supposed to do.

What do you see instead?

$ nyc bun test
process.binding("spawn_sync") is not implemented in Bun. If that breaks something, please file an issue and include a reproducible code sample.
error: script "test" exited with code 1

Additional information

An issue was filled for the same bug back in September. It was closed as completed by its author the same day for some reason.

paperdave commented 8 months ago

this can be implemented semi-easily in BunProcess.cpp, where the spawn_sync binding contains an object with a spawn function that points to a JS function that calls Bun.spawnSync, and remaps the output as node does. was going to add the good first issue tag but its not the most clear thing possible.