Module: ActionLink::VscodeSnippets
- Defined in:
- lib/action_link/vscode_snippets.rb
Overview
Installs the gem's VS Code snippets as a symlink inside the host
application's .vscode directory.
This runs in every process that boots the host application (Spring
preloader, Puma workers, rake tasks, ...), so those processes race each
other. A non-atomic remove-then-create (FileUtils.ln_s(force: true))
lets two processes both pass the "does it exist?" check before either
creates the link, so one of them dies with Errno::EEXIST on
symlink(2).
To stay race-free the link is created under a temporary name in the
system temp directory and then rename(2)-ed over the target, which
atomically replaces whatever is already there.
Class Method Summary collapse
Class Method Details
.install(target, source) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/action_link/vscode_snippets.rb', line 21 def install(target, source) target = target.to_s source = source.to_s return if already_linked?(target, source) install_atomically(target, source) end |