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

path.extname is deprecated. #148

Closed
gsfitis opened this issue Feb 15, 2017 · 5 comments
Closed

path.extname is deprecated. #148

gsfitis opened this issue Feb 15, 2017 · 5 comments

Comments

@gsfitis
Copy link

gsfitis commented Feb 15, 2017

Argument to path.extname must be a string

Object.extname (/opt/atom/resources/app.asar/src/electron-shims.js:20:10)
TagGenerator.getLanguage (/home/orion/.atom/packages/symbols-tree-view/lib/tag-generator.coffee:40:25)
TagGenerator.generate (/home/orion/.atom/packages/symbols-tree-view/lib/tag-generator.coffee:81:29)
SymbolsTreeView.generateTags (/home/orion/.atom/packages/symbols-tree-view/lib/symbols-tree-view.coffee:223:62)
SymbolsTreeView.populate (/home/orion/.atom/packages/symbols-tree-view/lib/symbols-tree-view.coffee:107:14)
<unknown> (/home/orion/.atom/packages/symbols-tree-view/lib/symbols-tree-view.coffee:272:24)
@XachaB
Copy link

XachaB commented Apr 7, 2017

Hi,

I fixed this in my local copy by changing the line 27 of tag-generatof.coffee to :

  return 'Cson' if (@path && path.extname(@path) in ['.cson', '.gyp'])

As I understand it, @path can be undefined, as it is obtained by doing filePath = editor.getPath().
Note that this is my first time looking at atom's code and at coffee script, which is why I'm not contributing code directly, but this seemed transparent enough.

@jerrykal
Copy link

jerrykal commented Apr 10, 2017

@xndcn Can you take a look??

I think @XachaB's solution is awesome 👍

@XachaB
Copy link

XachaB commented Apr 10, 2017

I did make a pull request, but I'd rather someone verify if this the correct way to check for undefined values. I did test on a minimal example on http://coffeescript.org/, and it looks like it's working locally on my machine, but I'm wondering if it wouldn't be better to use the existential "?" and write:

return 'Cson' if (@path? && path.extname(@path) in ['.cson', '.gyp'])

@nicolashainaux
Copy link

nicolashainaux commented Apr 11, 2017

I am no coffee script expert either, but @path? looks like the correct way of writing this.
I will include this in the next release (0.15.3) of my forked version.

It would have been interesting though to know what exactly triggers the bug (maybe files without extension?).

@sarangjo
Copy link
Collaborator

Duplicate of #140

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

5 participants