]> git.madduck.net Git - etc/vim.git/blob - autoload/ale/powershell.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / autoload / ale / powershell.vim
1 " Author: zigford <zigford@gmail.com>
2 " Description: Functions for integrating with Powershell linters.
3
4 " Write a powershell script to a temp file for execution
5 " return the command used to execute it
6 function! s:TemporaryPSScript(buffer, input) abort
7     let l:filename = 'script.ps1'
8     " Create a temp dir to house our temp .ps1 script
9     " a temp dir is needed as powershell needs the .ps1
10     " extension
11     let l:tempdir = ale#util#Tempname() . (has('win32') ? '\' : '/')
12     let l:tempscript = l:tempdir . l:filename
13     " Create the temporary directory for the file, unreadable by 'other'
14     " users.
15     call mkdir(l:tempdir, '', 0750)
16     " Automatically delete the directory later.
17     call ale#command#ManageDirectory(a:buffer, l:tempdir)
18     " Write the script input out to a file.
19     call ale#util#Writefile(a:buffer, a:input, l:tempscript)
20
21     return l:tempscript
22 endfunction
23
24 function! ale#powershell#RunPowerShell(buffer, base_var_name, command) abort
25     let l:executable = ale#Var(a:buffer, a:base_var_name . '_executable')
26     let l:tempscript = s:TemporaryPSScript(a:buffer, a:command)
27
28     return ale#Escape(l:executable)
29     \ . ' -Exe Bypass -NoProfile -File '
30     \ . ale#Escape(l:tempscript)
31     \ . ' %t'
32 endfunction