Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support glob inside npm scripts #875

Closed
brunoluiz opened this issue Feb 23, 2021 · 3 comments
Closed

Support glob inside npm scripts #875

brunoluiz opened this issue Feb 23, 2021 · 3 comments

Comments

@brunoluiz
Copy link

Currently, the following command produces what is expected, with the correct structure:

esbuild ./src/**/*.ts --outdir=dist

But, running the same command as an npm-script will not work, as npm itself seems to have a different way to do glob matching

{
  ...
  "scripts": { "build": "esbuild ./src/**/*.ts --outdir=dist" }
  ...
}
@brunoluiz
Copy link
Author

To be fair, it is probably because I use zsh, but internally npm uses sh or bash iirc. There are some projects (eslint, mocha) which bypass this by parsing globs when the input is specified inside single quote marks. In this case, esbuild with glob parsing would look like esbuild './src/**/*.ts' --outdir=dist

@evanw
Copy link
Owner

evanw commented Feb 24, 2021

I'm not going to encode zsh-specific features into esbuild. There are many different shells and I think it's best if esbuild remains shell-agnostic. There are also features specific to Windows Command Prompt that esbuild doesn't emulate, for example.

If you would like for this to work you are welcome to write a small script to do this yourself. I assume the most straightforward way to do this would be to use the glob package with esbuild's JavaScript API.

@brunoluiz
Copy link
Author

Makes sense. As it is a personal one-man project, I just ended up doing zsh -c 'esbuild ./src/**/*.ts --outdir=dist'. Would be nice to have this glob syntax as other projects do though (as mocha, eslint etc).

Anyways, closing it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants