diff options
author | w0rp <devw0rp@gmail.com> | 2018-04-13 20:49:03 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-04-13 20:49:03 +0100 |
commit | 56c7957a75d08b011c44cda7ec55864dd7cb5d31 (patch) | |
tree | 28ca73f28f383028626d72c8cd29704658a162d0 | |
parent | a0aa9aa9b721a73e81dd0091f37826d5e8a336d2 (diff) | |
download | ale-56c7957a75d08b011c44cda7ec55864dd7cb5d31.zip |
#1277 Try to get eslint_d to run the right version of eslint
-rw-r--r-- | autoload/ale/handlers/eslint.vim | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/autoload/ale/handlers/eslint.vim b/autoload/ale/handlers/eslint.vim index bc10ec21..47a2a866 100644 --- a/autoload/ale/handlers/eslint.vim +++ b/autoload/ale/handlers/eslint.vim @@ -41,8 +41,19 @@ function! ale#handlers#eslint#GetCommand(buffer) abort let l:executable = ale#handlers#eslint#GetExecutable(a:buffer) let l:options = ale#Var(a:buffer, 'javascript_eslint_options') + let l:cd_string = '' - return ale#node#Executable(a:buffer, l:executable) + " Change directory to where `node_modules` is, if running eslint_d. + " eslint_d looks up which eslint version to use based on the CWD. + if l:executable =~# 'eslint_d' + let l:node_modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') + + if !empty(l:node_modules_dir) + let l:cd_string = ale#path#CdString(l:node_modules_dir) + endif + endif + + return l:cd_string . ale#node#Executable(a:buffer, l:executable) \ . (!empty(l:options) ? ' ' . l:options : '') \ . ' -f unix --stdin --stdin-filename %s' endfunction |