Simplfy semver handling and share the semver version cache across everything

This commit is contained in:
w0rp
2017-11-09 23:42:54 +00:00
parent 911b6d8f71
commit a8c5e0f4dc
12 changed files with 133 additions and 188 deletions

View File

@@ -23,18 +23,15 @@ function! ale_linters#javascript#flow#GetCommand(buffer, version_lines) abort
return ''
endif
let l:use_respect_pragma = 1
let l:executable = ale_linters#javascript#flow#GetExecutable(a:buffer)
let l:version = ale#semver#GetVersion(l:executable, a:version_lines)
" If we can parse the version number, then only use --respect-pragma
" if the version is >= 0.36.0, which added the argument.
for l:match in ale#util#GetMatches(a:version_lines, '\v\d+\.\d+\.\d+$')
let l:use_respect_pragma = ale#semver#GreaterOrEqual(
\ ale#semver#Parse(l:match[0]),
\ [0, 36, 0]
\)
endfor
let l:use_respect_pragma = empty(l:version)
\ || ale#semver#GTE(l:version, [0, 36])
return ale#Escape(ale_linters#javascript#flow#GetExecutable(a:buffer))
return ale#Escape(l:executable)
\ . ' check-contents'
\ . (l:use_respect_pragma ? ' --respect-pragma': '')
\ . ' --json --from ale %s'