TypeError: Cannot read property 'patternOnly' of undefined
Closed this issue · 7 comments
ubuntu 16.10,
node v7.7.3
open-in-editor 2.0.0
$ env | grep EDITOR
EDITOR=/usr/bin/vim
$ ./node_modules/.bin/oe index.js:1
TypeError: Cannot read property 'patternOnly' of undefined
The same error is reproduced for the cmd
option:
var openInEditor = require('open-in-editor');
var editor = openInEditor.configure({
cmd: 'visual-studio-code -r -g {filename}:{line}:{column}'
});
editor.open('index.js:1').catch(err => { console.error(err) });
$ node index.js
TypeError: Cannot read property 'patternOnly' of undefined
I'm not sure, but probably it's because process.platform
not a darwin
and we have a mistake (here)[https://github.com/lahmatiy/open-in-editor/blob/v2.0.0/lib/editors/vim.js#L26]. But it's should to another error.
I've fixed an issue and published 2.1. Can you test it?
$ ./bin/oe --version
2.1.0
$ ./bin/oe package.json
TypeError: Cannot read property 'patternOnly' of undefined
@lahmatiy The error message looks like the options is undefined
then the open
function has called.
I've just noted what the options
is not passed to the open
function if just the cmd
is defined (look at please
https://github.com/lahmatiy/open-in-editor/blob/master/lib/index.js#L28 ). Could the root cause happen here?
It would be nice if the cmd
option could be passed to the configure
method together with other options. The editor
option, for example:
var editor = openInEditor.configure({
editor: 'code',
cmd: 'visual-studio-code' // just the custom editor's path, and the pattern will be guessed
});
In the ideal solution if the editor's path has being taken from environment variables (it's the '/usr/bin/vim', for example) the pattern
option with an additional editor's command line agruments should be guessed automatically if the editor is known.
The error message looks like the options is undefined then the open function has called.
I've just noted what the options is not passed to the open function if just the cmd is defined (look at please
https://github.com/lahmatiy/open-in-editor/blob/master/lib/index.js#L28 ). Could the root cause happen here?
Yep, you're right, that's the cause of the problem – fixed
It would be nice if the cmd option could be passed to the configure method together with other options. The editor option, for example
Sounds reasonable, it's possible now. And I've changed behaviour to get an editor settings when editor
and cmd
are set.
In the ideal solution if the editor's path has being taken from environment variables (it's the '/usr/bin/vim', for example) the pattern option with an additional editor's command line agruments should be guessed automatically if the editor is known.
When editor
or cmd
is set, environment variables are not using. It's by design and if we change it there is no way to override environment settings.
Ecxellent! Thank you very much.