Fix #895 - Run Node.js scripts with node.exe instead of node on Windows
This commit is contained in:
@@ -28,16 +28,8 @@ function! ale#fixers#eslint#Fix(buffer) abort
|
||||
return 0
|
||||
endif
|
||||
|
||||
if ale#Has('win32') && l:executable =~? 'eslint\.js$'
|
||||
" For Windows, if we detect an eslint.js script, we need to execute
|
||||
" it with node, or the file can be opened with a text editor.
|
||||
let l:head = 'node ' . ale#Escape(l:executable)
|
||||
else
|
||||
let l:head = ale#Escape(l:executable)
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:head
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' --config ' . ale#Escape(l:config)
|
||||
\ . ' --fix %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
|
||||
@@ -11,16 +11,8 @@ endfunction
|
||||
function! ale#fixers#standard#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#standard#GetExecutable(a:buffer)
|
||||
|
||||
if ale#Has('win32') && l:executable =~? 'cmd\.js$'
|
||||
" For Windows, if we detect an standard.js script, we need to execute
|
||||
" it with node, or the file can be opened with a text editor.
|
||||
let l:head = 'node ' . ale#Escape(l:executable)
|
||||
else
|
||||
let l:head = ale#Escape(l:executable)
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:head
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' --fix %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
@@ -15,16 +15,8 @@ endfunction
|
||||
function! ale#fixers#stylelint#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer)
|
||||
|
||||
if ale#Has('win32') && l:executable =~? 'stylelint\.js$'
|
||||
" For Windows, if we detect an stylelint.js script, we need to execute
|
||||
" it with node, or the file can be opened with a text editor.
|
||||
let l:head = 'node ' . ale#Escape(l:executable)
|
||||
else
|
||||
let l:head = ale#Escape(l:executable)
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'command': l:head
|
||||
\ 'command': ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' --fix %t',
|
||||
\ 'read_temporary_file': 1,
|
||||
\}
|
||||
|
||||
@@ -17,17 +17,9 @@ endfunction
|
||||
function! ale#handlers#eslint#GetCommand(buffer) abort
|
||||
let l:executable = ale#handlers#eslint#GetExecutable(a:buffer)
|
||||
|
||||
if ale#Has('win32') && l:executable =~? 'eslint\.js$'
|
||||
" For Windows, if we detect an eslint.js script, we need to execute
|
||||
" it with node, or the file can be opened with a text editor.
|
||||
let l:head = 'node ' . ale#Escape(l:executable)
|
||||
else
|
||||
let l:head = ale#Escape(l:executable)
|
||||
endif
|
||||
|
||||
let l:options = ale#Var(a:buffer, 'javascript_eslint_options')
|
||||
|
||||
return l:head
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -f unix --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Functions for working with Node executables.
|
||||
|
||||
call ale#Set('windows_node_executable_path', 'node.exe')
|
||||
|
||||
" Given a buffer number, a base variable name, and a list of paths to search
|
||||
" for in ancestor directories, detect the executable path for a Node program.
|
||||
"
|
||||
@@ -20,3 +22,21 @@ function! ale#node#FindExecutable(buffer, base_var_name, path_list) abort
|
||||
|
||||
return ale#Var(a:buffer, a:base_var_name . '_executable')
|
||||
endfunction
|
||||
|
||||
" Create a executable string which executes a Node.js script command with a
|
||||
" Node.js executable if needed.
|
||||
"
|
||||
" The executable string should not be escaped before passing it to this
|
||||
" function, the executable string will be escaped when returned by this
|
||||
" function.
|
||||
"
|
||||
" The executable is only prefixed for Windows machines
|
||||
function! ale#node#Executable(buffer, executable) abort
|
||||
if ale#Has('win32') && a:executable =~? '\.js$'
|
||||
let l:node = ale#Var(a:buffer, 'windows_node_executable_path')
|
||||
|
||||
return ale#Escape(l:node) . ' ' . ale#Escape(a:executable)
|
||||
endif
|
||||
|
||||
return ale#Escape(a:executable)
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user