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

Glob not working when not matching _exactly_ two files (and error message is misleading) #79

Closed
arve0 opened this issue Jan 15, 2019 · 3 comments

Comments

@arve0
Copy link
Contributor

arve0 commented Jan 15, 2019

No response on comment yet, so opening an issue.

Has anything changed in 1.6.0? Cannot get globs to work:

C:\Temp\sme>npm i -g source-map-explorer
C:\Users\_\AppData\Roaming\npm\source-map-explorer -> C:\Users\_\AppDa
ta\Roaming\npm\node_modules\source-map-explorer\index.js
+ source-map-explorer@1.6.0
updated 1 package in 0.957s

C:\Temp\sme>source-map-explorer --version
1.6.0

C:\Temp\sme>source-map-explorer main.*
File not found! --  ENOENT: no such file or directory, open 'main.*'

C:\Temp\sme>dir main.*
 Volumet i stasjon C er OSDisk
 Volumserienummeret er F65B-C808

 Innhold i C:\Temp\sme

11.01.2019  08:36             2 146 main.js
               1 fil(er)            2 146 byte
               0 mappe(r)   9 305 964 544 byte ledig

C:\Temp\sme>
@arve0
Copy link
Contributor Author

arve0 commented Jan 15, 2019

I get same results in 1.4.0 and 1.5.0:

C:\Temp\sme>source-map-explorer --version
1.5.0

C:\Temp\sme>source-map-explorer main.*
File not found! --  ENOENT: no such file or directory, open 'main.*'

C:\Temp\sme>source-map-explorer --version
1.4.0

C:\Temp\sme>source-map-explorer main.*
File not found! --  ENOENT: no such file or directory, open 'main.*'

For reference, glob was originally verified in facebook/create-react-app#2717

@arve0
Copy link
Contributor Author

arve0 commented Jan 15, 2019

After debugging, I see that glob is only working when it also matches .map file. For example:

  • Files main.1234.js and main.1324.js.map exists
  • Using glob main.*.js*, ending star will make it match both files

Code: https://github.com/danvk/source-map-explorer/blob/master/index.js#L203

This is a bit unintuitive, as <script.map.js> is an optional parameter.

@arve0
Copy link
Contributor Author

arve0 commented Jan 15, 2019

Proposed fix:

A. If .map is not given, shim as args['<script.js>'] + ".map" and glob for each of them.
B. Fail hard when it does not match exactly two files: https://github.com/danvk/source-map-explorer/blob/master/index.js#L200
C. Add trailing star to glob if it does only match one file.
D. If it matches one file, see if match + ".map" exists.

Let me know what you prefer, and I'll send a PR.

Edit: Added option D.

@arve0 arve0 changed the title Globs on windows not working? Glob not working when not matching _exactly_ two files (and no error is given) Jan 15, 2019
@arve0 arve0 changed the title Glob not working when not matching _exactly_ two files (and no error is given) Glob not working when not matching _exactly_ two files (and error message is misleading) Jan 15, 2019
arve0 added a commit to arve0/source-map-explorer that referenced this issue Jan 15, 2019
This was referenced Jan 15, 2019
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