oven-sh / bun

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

bun script sould be run in package.json directory #8158

Open yukulele opened 9 months ago

yukulele commented 9 months ago

What version of Bun is running?

1.0.22+b400b36ca

What platform is your computer?

Linux 5.15.0-58-generic x86_64 x86_64

What steps can reproduce the bug?

(In this example I'm in /home/me/my-project/ directory.)

  1. create a pwd script in package.json:

    {
    "script": {
      "pwd": "pwd"
    }
    } 
  2. create a sub directory and cd it

    mkdir foo
    cd ./foo/

run pwd script

bun run pwd

What is the expected behavior?

/home/me/my-project

What do you see instead?

/home/me/my-project/foo

Additional information

compare with npm:

> cd /home/me/my-project/
> npm run pwd
/home/me/my-project
> bun run pwd
/home/me/my-project      # OK
> cd ./foo
> npm run pwd
/home/me/my-project
> bun run pwd
/home/me/my-project/foo  # NOT OK
dvlpr91 commented 8 months ago

Right, is this a bug?

dvlpr91 commented 8 months ago

I suffered for 4 hours in vain because of this.

kitten commented 8 months ago

As per the npm-run-script docs, the INIT_CWD environment variable is also not being set.

KholdStare commented 1 week ago

This is an issue for me as well, as with yarn workspaces, I was able to define re-usable scripts in one central place, and run them in any directory I needed, with INIT_CWD helping that. Using bun run --filter script-package someGlobalScript doesn't work from any directory anymore.