vagrant-fsnotify 0.0.6 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/AUTHORS +7 -0
- data/CHANGELOG.md +50 -0
- data/Gemfile +2 -2
- data/LICENSE +1 -1
- data/README.md +211 -1
- data/Vagrantfile +7 -115
- data/lib/vagrant-fsnotify/command-fsnotify.rb +81 -11
- data/lib/vagrant-fsnotify/config-fsnotify.rb +29 -0
- data/lib/vagrant-fsnotify/plugin.rb +11 -2
- data/lib/vagrant-fsnotify/version.rb +1 -1
- data/vagrant-fsnotify.gemspec +2 -4
- metadata +20 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 67c49ed58e768b8d862c56a16758935e722abd51c92f44bcba26affe5a4c8c02
|
4
|
+
data.tar.gz: 1f17acfa20d968e6b9ac1aea5aeedf2a4465859966edc54b1254e6a59d23a378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8390dfed9fd75c925da986d2ef422eae14b410f55f720fab93a132231d54453452459b3c124cae077e165a541ec518db4c79b913b814011cef7e4f234de2d513
|
7
|
+
data.tar.gz: 2ca844f611778d2b139f6c792ae2c82f13dd91a5ec07f07d12532e93572c229756519eca82befead5a6b5c70ddb0f51ca0d1389d5b721f827bc052be9802de2f
|
data/AUTHORS
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
0.3.2 - 2021-07-12
|
2
|
+
==================
|
3
|
+
- Add parameter to allow selection of touch flags
|
4
|
+
|
5
|
+
0.3.1 - 2019-04-11
|
6
|
+
==================
|
7
|
+
- Update mtime as well as atime to trigger file events on the guest (#28)
|
8
|
+
|
9
|
+
0.3.0 - 2016-04-13
|
10
|
+
==================
|
11
|
+
- Fix for "No such file or directory" on Windows host (#11)
|
12
|
+
|
13
|
+
0.2.0 - 2015-07-14
|
14
|
+
==================
|
15
|
+
- *Breaking change:* Minimum required Vagrant version changed to 1.7.3+
|
16
|
+
- Fixed a dependency issue with celluloid (#10, @leafac)
|
17
|
+
|
18
|
+
0.1.1 - 2015-07-05 (yanked)
|
19
|
+
===========================
|
20
|
+
Note: This release was yanked due to a dependency issue, see #9
|
21
|
+
- Added command synopsis (#7, @leafac)
|
22
|
+
- Fix issue with vagrant runtime dependency on celluloid (#8, @leafac)
|
23
|
+
|
24
|
+
0.1.0 - 2015-07-05 (yanked)
|
25
|
+
===========================
|
26
|
+
Note: This release was yanked due to a dependency issue, see #9
|
27
|
+
- *Breaking change:* Added support for forwading file addition/removal (#6, @leafac)
|
28
|
+
- Depend on `vagrant` rather than `listen` for better compatibility with upstream (#5, @leafac)
|
29
|
+
- Added documentation (#3 & #4, @leafac)
|
30
|
+
|
31
|
+
0.0.6 - 2015-04-16
|
32
|
+
==================
|
33
|
+
- Fix multimachine use, allow specifying which machine to target (@elskwid)
|
34
|
+
|
35
|
+
0.0.5 - 2015-04-11
|
36
|
+
==================
|
37
|
+
- Fix `listen` dependency
|
38
|
+
|
39
|
+
0.0.4 - 2014-08-18
|
40
|
+
==================
|
41
|
+
- Uses access time modification, rather than modified time
|
42
|
+
|
43
|
+
0.0.3 - 2014-08-15
|
44
|
+
==================
|
45
|
+
- Allow guest path overriding
|
46
|
+
|
47
|
+
|
48
|
+
0.0.2 - 2014-08-15
|
49
|
+
==================
|
50
|
+
- Increase the delay between changes to 2 seconds
|
data/Gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem "vagrant", git: "https://github.com/
|
4
|
+
gem "vagrant", git: "https://github.com/hashicorp/vagrant.git", ref: 'v2.2.18'
|
5
5
|
end
|
6
6
|
|
7
7
|
group :plugins do
|
8
|
-
|
8
|
+
gem "vagrant-fsnotify", path: "."
|
9
9
|
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,214 @@
|
|
1
1
|
vagrant-fsnotify
|
2
2
|
================
|
3
3
|
|
4
|
-
Forward filesystem change notifications to your Vagrant VM
|
4
|
+
Forward filesystem change notifications to your [Vagrant][vagrant] VM.
|
5
|
+
|
6
|
+
Problem
|
7
|
+
-------
|
8
|
+
|
9
|
+
Some filesystems (e.g. ext4, HFS+) have a feature of event notification.
|
10
|
+
Interested applications can subscribe and are notified when filesystem events
|
11
|
+
happen (e.g. a file was created, modified or deleted).
|
12
|
+
|
13
|
+
Applications can make use of this system to provide features such as auto-reload
|
14
|
+
or live updates. For example, [Jekyll][jekyll] regenerates the static website
|
15
|
+
and [Guard][guard] triggers a test run or a build when source files are
|
16
|
+
modified.
|
17
|
+
|
18
|
+
Unfortunately, [Vagrant][vagrant] users have a hard time making use of these
|
19
|
+
features when the application is running inside a virtual machine. When the file
|
20
|
+
is modified on the host, the event is not propagated to the guest and the
|
21
|
+
auto-reload never happens.
|
22
|
+
|
23
|
+
There are several bug reports related to this issue:
|
24
|
+
|
25
|
+
- <https://www.virtualbox.org/ticket/10660>
|
26
|
+
- <https://github.com/guard/listen/issues/53>
|
27
|
+
- <https://github.com/guard/listen/issues/57>
|
28
|
+
- <https://github.com/guard/guard/issues/269>
|
29
|
+
- <https://github.com/mitchellh/vagrant/issues/707>
|
30
|
+
|
31
|
+
There are two generally accepted solutions. The first is fall back to long
|
32
|
+
polling, the other is to
|
33
|
+
[forward the events over TCP][forwarding-file-events-over-tcp]. The problem with
|
34
|
+
long polling is that it's painfully slow, especially in shared folders. The
|
35
|
+
problem with forwarding events is that it's not a general approach that works
|
36
|
+
for any application.
|
37
|
+
|
38
|
+
Solution
|
39
|
+
--------
|
40
|
+
|
41
|
+
`vagrant-fsnotify` proposes a different solution: run a process listening for
|
42
|
+
filesystem events on the host and, when a notification is received, access the
|
43
|
+
virtual machine guest and `touch` the file in there (or `touch` followed by a
|
44
|
+
`rm` in case of file removals), causing an event to be propagated on the guest
|
45
|
+
filesystem.
|
46
|
+
|
47
|
+
This leverages the speed of using real filesystem events while still being
|
48
|
+
general enough to don't require any support from applications.
|
49
|
+
|
50
|
+
Caveats
|
51
|
+
-------
|
52
|
+
|
53
|
+
Due to the nature of filesystem events and the fact that `vagrant-fsnotify` uses
|
54
|
+
`touch`, the events are triggerred back on the host a second time. To avoid
|
55
|
+
infinite loops, we add an arbitrary debounce of 2 seconds between `touch`-ing
|
56
|
+
the same file. Thus, if a file is modified on the host more than once in 2
|
57
|
+
seconds the VM will only see one notification. If the second trigger on the
|
58
|
+
host or this arbitrary debounce is unacceptable for your application,
|
59
|
+
`vagrant-fsnotify` might not be for you.
|
60
|
+
|
61
|
+
Installation
|
62
|
+
------------
|
63
|
+
|
64
|
+
`vagrant-fsnotify` is a [Vagrant][vagrant] plugin and can be installed by
|
65
|
+
running:
|
66
|
+
|
67
|
+
```console
|
68
|
+
$ vagrant plugin install vagrant-fsnotify
|
69
|
+
```
|
70
|
+
|
71
|
+
[Vagrant][vagrant] version 1.7.3 or greater is required.
|
72
|
+
|
73
|
+
Usage
|
74
|
+
-----
|
75
|
+
|
76
|
+
### Basic setup
|
77
|
+
|
78
|
+
In `Vagrantfile` synced folder configuration, add the `fsnotify: true`
|
79
|
+
option. For example, in order to enable `vagrant-fsnotify` for the the default
|
80
|
+
`/vagrant` shared folder, add the following:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
config.vm.synced_folder ".", "/vagrant", fsnotify: true
|
84
|
+
```
|
85
|
+
|
86
|
+
When the guest virtual machine is up, run the following:
|
87
|
+
|
88
|
+
```console
|
89
|
+
$ vagrant fsnotify
|
90
|
+
```
|
91
|
+
|
92
|
+
This starts the long running process that captures filesystem events on the host
|
93
|
+
and forwards them to the guest virtual machine.
|
94
|
+
|
95
|
+
### Run automatically on vagrant up
|
96
|
+
|
97
|
+
To have `vagrant fsnotify` start automatically with your guest, you can use triggers. Add this to your `Vagrantfile`:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
config.trigger.after :up do |t|
|
101
|
+
t.name = "vagrant-fsnotify"
|
102
|
+
t.run = { inline: "vagrant fsnotify" }
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
106
|
+
Now, whenever you run `vagrant up`, `vagrant fsnotify` will be run as well. Learn more at https://www.vagrantup.com/docs/triggers/
|
107
|
+
|
108
|
+
### Multi-VM environments
|
109
|
+
|
110
|
+
In multi-VM environments, you can specify the name of the VMs targeted by
|
111
|
+
`vagrant-fsnotify` using:
|
112
|
+
|
113
|
+
```console
|
114
|
+
$ vagrant fsnotify <vm-name-1> <vm-name-2> ...
|
115
|
+
```
|
116
|
+
|
117
|
+
### Excluding files
|
118
|
+
|
119
|
+
To exclude files or directories from being watched, you can add an `:exclude`
|
120
|
+
option, which takes an array of strings (matched as a regexp against relative
|
121
|
+
paths):
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
config.vm.synced_folder ".", "/vagrant", fsnotify: true,
|
125
|
+
exclude: ["path1", "some/directory"]
|
126
|
+
```
|
127
|
+
|
128
|
+
This will exclude all files inside the `path1` and `some/directory`. It will
|
129
|
+
also exclude files such as `another/directory/path1`
|
130
|
+
|
131
|
+
### Guest path override
|
132
|
+
|
133
|
+
If your actual path on the VM is not the same as the one in `synced_folder`, for
|
134
|
+
example when using [`vagrant-bindfs`][vagrant-bindfs], you can use the
|
135
|
+
`:override_guestpath` option:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
config.vm.synced_folder ".", "/vagrant", fsnotify: true,
|
139
|
+
override_guestpath: "/real/path"
|
140
|
+
```
|
141
|
+
|
142
|
+
This will forward a notification on `./myfile` to `/real/path/myfile` instead of
|
143
|
+
`/vagrant/myfile`.
|
144
|
+
|
145
|
+
### Select filesystem events
|
146
|
+
|
147
|
+
By default, when the `:fsnotify` key in the `Vagrantfile` is configured with
|
148
|
+
`true`, all filesystem events are forwarded to the VM (i.e. file creation,
|
149
|
+
modification and removal events). If, instead, you want to select only a few of
|
150
|
+
those events to be forwarded (e.g. you don't care about file removals), you can
|
151
|
+
use an Array of Symbols among the following options: `:added`, `:modified` and
|
152
|
+
`:removed`.
|
153
|
+
|
154
|
+
For example, to forward only added files events to the default `/vagrant`
|
155
|
+
folder, add the following to the `Vagrantfile`:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
config.vm.synced_folder ".", "/vagrant", fsnotify: [:added]
|
159
|
+
```
|
160
|
+
|
161
|
+
### Set touch flags
|
162
|
+
|
163
|
+
By default, the touch command on the VM will be run with modification flag and access flag, setting
|
164
|
+
both modification and access attributes of the file. If only either flag should be used the `:touch`
|
165
|
+
param can be set per machine config in the `Vagrantfile`. The param supports an array with either or both
|
166
|
+
`:modification` and `:access` values.
|
167
|
+
|
168
|
+
As example, to only set the access attribute of files when they have changed on the host system set the following
|
169
|
+
in the `Vagrantfile`:
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
config.fsnotify.touch = [:access]
|
173
|
+
```
|
174
|
+
or for instances and providers
|
175
|
+
```ruby
|
176
|
+
config.vm.define "vm" do |instance|
|
177
|
+
instance.fsnotify.touch = [:access]
|
178
|
+
end
|
179
|
+
```
|
180
|
+
|
181
|
+
Development
|
182
|
+
-------------
|
183
|
+
|
184
|
+
To hack on `vagrant-fsnotify`, you need a recent ruby and virtualbox installed.
|
185
|
+
|
186
|
+
Then, after cloning the repo:
|
187
|
+
```shell
|
188
|
+
# install development gems
|
189
|
+
bundle install
|
190
|
+
|
191
|
+
# run vagrant commands by prefixing them with `bundle exec` to run with the plugin installed from source
|
192
|
+
# this will launch a basic ubuntu VM and monitor file changes on the current directory
|
193
|
+
bundle exec vagrant up
|
194
|
+
|
195
|
+
# make changes to the code
|
196
|
+
vim lib/vagrant-fsnotify/command-fsnotify.rb
|
197
|
+
...
|
198
|
+
|
199
|
+
# relaunch the process to activate your changes
|
200
|
+
bundle exec vagrant fsnotify
|
201
|
+
```
|
202
|
+
|
203
|
+
Original work
|
204
|
+
-------------
|
205
|
+
|
206
|
+
This plugin used [`vagrant-rsync-back`][vagrant-rsync-back] by @smerill and the
|
207
|
+
[Vagrant][vagrant] source code as a starting point.
|
208
|
+
|
209
|
+
[vagrant]: https://www.vagrantup.com/
|
210
|
+
[jekyll]: http://jekyllrb.com/
|
211
|
+
[guard]: http://guardgem.org/
|
212
|
+
[forwarding-file-events-over-tcp]: https://github.com/guard/listen#forwarding-file-events-over-tcp
|
213
|
+
[vagrant-bindfs]: https://github.com/gael-ian/vagrant-bindfs
|
214
|
+
[vagrant-rsync-back]: https://github.com/smerrill/vagrant-rsync-back
|
data/Vagrantfile
CHANGED
@@ -1,122 +1,14 @@
|
|
1
1
|
# -*- mode: ruby -*-
|
2
2
|
# vi: set ft=ruby :
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
8
|
-
# All Vagrant configuration is done here. The most common configuration
|
9
|
-
# options are documented and commented below. For a complete reference,
|
10
|
-
# please see the online documentation at vagrantup.com.
|
11
|
-
|
12
|
-
# Every Vagrant virtual environment requires a box to build off of.
|
13
|
-
config.vm.box = "ubuntu/trusty64"
|
14
|
-
|
15
|
-
# Disable automatic box update checking. If you disable this, then
|
16
|
-
# boxes will only be checked for updates when the user runs
|
17
|
-
# `vagrant box outdated`. This is not recommended.
|
18
|
-
# config.vm.box_check_update = false
|
19
|
-
|
20
|
-
# Create a forwarded port mapping which allows access to a specific port
|
21
|
-
# within the machine from a port on the host machine. In the example below,
|
22
|
-
# accessing "localhost:8080" will access port 80 on the guest machine.
|
23
|
-
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
24
|
-
|
25
|
-
# Create a private network, which allows host-only access to the machine
|
26
|
-
# using a specific IP.
|
27
|
-
config.vm.network "private_network", ip: "192.168.33.10"
|
28
|
-
|
29
|
-
# Create a public network, which generally matched to bridged network.
|
30
|
-
# Bridged networks make the machine appear as another physical device on
|
31
|
-
# your network.
|
32
|
-
# config.vm.network "public_network"
|
33
|
-
|
34
|
-
# If true, then any SSH connections made will enable agent forwarding.
|
35
|
-
# Default value: false
|
36
|
-
# config.ssh.forward_agent = true
|
37
|
-
|
38
|
-
# Share an additional folder to the guest VM. The first argument is
|
39
|
-
# the path on the host to the actual folder. The second argument is
|
40
|
-
# the path on the guest to mount the folder. And the optional third
|
41
|
-
# argument is a set of non-required options.
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "ubuntu/bionic64"
|
42
6
|
config.vm.synced_folder ".", "/vagrant", fsnotify: true
|
43
7
|
|
44
|
-
|
45
|
-
# backing providers for Vagrant. These expose provider-specific options.
|
46
|
-
# Example for VirtualBox:
|
47
|
-
#
|
48
|
-
# config.vm.provider "virtualbox" do |vb|
|
49
|
-
# # Don't boot with headless mode
|
50
|
-
# vb.gui = true
|
51
|
-
#
|
52
|
-
# # Use VBoxManage to customize the VM. For example to change memory:
|
53
|
-
# vb.customize ["modifyvm", :id, "--memory", "1024"]
|
54
|
-
# end
|
55
|
-
#
|
56
|
-
# View the documentation for the provider you're using for more
|
57
|
-
# information on available options.
|
58
|
-
|
59
|
-
# Enable provisioning with CFEngine. CFEngine Community packages are
|
60
|
-
# automatically installed. For example, configure the host as a
|
61
|
-
# policy server and optionally a policy file to run:
|
62
|
-
#
|
63
|
-
# config.vm.provision "cfengine" do |cf|
|
64
|
-
# cf.am_policy_hub = true
|
65
|
-
# # cf.run_file = "motd.cf"
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
# You can also configure and bootstrap a client to an existing
|
69
|
-
# policy server:
|
70
|
-
#
|
71
|
-
# config.vm.provision "cfengine" do |cf|
|
72
|
-
# cf.policy_server_address = "10.0.2.15"
|
73
|
-
# end
|
74
|
-
|
75
|
-
# Enable provisioning with Puppet stand alone. Puppet manifests
|
76
|
-
# are contained in a directory path relative to this Vagrantfile.
|
77
|
-
# You will need to create the manifests directory and a manifest in
|
78
|
-
# the file default.pp in the manifests_path directory.
|
79
|
-
#
|
80
|
-
# config.vm.provision "puppet" do |puppet|
|
81
|
-
# puppet.manifests_path = "manifests"
|
82
|
-
# puppet.manifest_file = "site.pp"
|
83
|
-
# end
|
84
|
-
|
85
|
-
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
86
|
-
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
87
|
-
# some recipes and/or roles.
|
88
|
-
#
|
89
|
-
# config.vm.provision "chef_solo" do |chef|
|
90
|
-
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
91
|
-
# chef.roles_path = "../my-recipes/roles"
|
92
|
-
# chef.data_bags_path = "../my-recipes/data_bags"
|
93
|
-
# chef.add_recipe "mysql"
|
94
|
-
# chef.add_role "web"
|
95
|
-
#
|
96
|
-
# # You may also specify custom JSON attributes:
|
97
|
-
# chef.json = { mysql_password: "foo" }
|
98
|
-
# end
|
8
|
+
config.vm.provision "shell", inline: "sudo apt-get update && sudo apt-get install -y inotify-tools"
|
99
9
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
# ORGNAME in the URL and validation key.
|
105
|
-
#
|
106
|
-
# If you have your own Chef Server, use the appropriate URL, which may be
|
107
|
-
# HTTP instead of HTTPS depending on your configuration. Also change the
|
108
|
-
# validation key to validation.pem.
|
109
|
-
#
|
110
|
-
# config.vm.provision "chef_client" do |chef|
|
111
|
-
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
112
|
-
# chef.validation_key_path = "ORGNAME-validator.pem"
|
113
|
-
# end
|
114
|
-
#
|
115
|
-
# If you're using the Opscode platform, your validator client is
|
116
|
-
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
117
|
-
#
|
118
|
-
# If you have your own Chef Server, the default validation client name is
|
119
|
-
# chef-validator, unless you changed the configuration.
|
120
|
-
#
|
121
|
-
# chef.validation_client_name = "ORGNAME-validator"
|
10
|
+
config.trigger.after :up do |t|
|
11
|
+
t.name = "vagrant-fsnotify"
|
12
|
+
t.run = { inline: "bundle exec vagrant fsnotify" }
|
13
|
+
end
|
122
14
|
end
|
@@ -4,6 +4,10 @@ module VagrantPlugins::Fsnotify
|
|
4
4
|
class Command < Vagrant.plugin("2", :command)
|
5
5
|
include Vagrant::Action::Builtin::MixinSyncedFolders
|
6
6
|
|
7
|
+
def self.synopsis
|
8
|
+
'forwards filesystem events to virtual machine'
|
9
|
+
end
|
10
|
+
|
7
11
|
def execute
|
8
12
|
@logger = Log4r::Logger.new("vagrant::commands::fsnotify")
|
9
13
|
|
@@ -29,18 +33,25 @@ module VagrantPlugins::Fsnotify
|
|
29
33
|
|
30
34
|
folder.each do |id, opts|
|
31
35
|
|
32
|
-
|
36
|
+
if !(
|
37
|
+
(opts[:fsnotify] == true) ||
|
38
|
+
(
|
39
|
+
opts[:fsnotify].respond_to?(:include?) &&
|
40
|
+
(
|
41
|
+
opts[:fsnotify].include?(:modified) ||
|
42
|
+
opts[:fsnotify].include?(:added) ||
|
43
|
+
opts[:fsnotify].include?(:removed)
|
44
|
+
)
|
45
|
+
)
|
46
|
+
)
|
47
|
+
next
|
48
|
+
end
|
33
49
|
|
34
50
|
# Folder info
|
35
51
|
hostpath = opts[:hostpath]
|
36
52
|
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
37
53
|
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
38
54
|
|
39
|
-
if Vagrant::Util::Platform.windows?
|
40
|
-
# rsync for Windows expects cygwin style paths, always.
|
41
|
-
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
42
|
-
end
|
43
|
-
|
44
55
|
# Make sure the host path ends with a "/" to avoid creating
|
45
56
|
# a nested directory...
|
46
57
|
if !hostpath.end_with?("/")
|
@@ -68,7 +79,27 @@ module VagrantPlugins::Fsnotify
|
|
68
79
|
end
|
69
80
|
|
70
81
|
if paths.empty?
|
71
|
-
@env.ui.info(
|
82
|
+
@env.ui.info(<<-MESSAGE)
|
83
|
+
Nothing to sync.
|
84
|
+
|
85
|
+
Note that the valid values for the `:fsnotify' configuration key on
|
86
|
+
`Vagrantfile' are either `true' (which forwards all kinds of filesystem events)
|
87
|
+
or an Array containing symbols among the following options: `:modified',
|
88
|
+
`:added' and `:removed' (in which case, only the specified filesystem events are
|
89
|
+
forwarded).
|
90
|
+
|
91
|
+
For example, to forward all filesystem events to the default `/vagrant' folder,
|
92
|
+
add the following to the `Vagrantfile':
|
93
|
+
|
94
|
+
config.vm.synced_folder ".", "/vagrant", fsnotify: true
|
95
|
+
|
96
|
+
And to forward only added files events to the default `/vagrant' folder, add the
|
97
|
+
following to the `Vagrantfile':
|
98
|
+
|
99
|
+
config.vm.synced_folder ".", "/vagrant", fsnotify: [:added]
|
100
|
+
|
101
|
+
Exiting...
|
102
|
+
MESSAGE
|
72
103
|
return 1
|
73
104
|
end
|
74
105
|
|
@@ -95,7 +126,7 @@ module VagrantPlugins::Fsnotify
|
|
95
126
|
Vagrant::Util::Busy.busy(callback) do
|
96
127
|
listener.start
|
97
128
|
queue.pop
|
98
|
-
listener.stop if listener.
|
129
|
+
listener.stop if listener.state != :stopped
|
99
130
|
end
|
100
131
|
|
101
132
|
return 0
|
@@ -113,10 +144,26 @@ module VagrantPlugins::Fsnotify
|
|
113
144
|
end
|
114
145
|
|
115
146
|
tosync = {}
|
147
|
+
todelete = []
|
116
148
|
|
117
149
|
paths.each do |hostpath, folder|
|
118
150
|
|
119
|
-
|
151
|
+
toanalyze = []
|
152
|
+
if folder[:opts][:fsnotify] == true
|
153
|
+
toanalyze += modified + added + removed
|
154
|
+
else
|
155
|
+
if folder[:opts][:fsnotify].include? :modified
|
156
|
+
toanalyze += modified
|
157
|
+
end
|
158
|
+
if folder[:opts][:fsnotify].include? :added
|
159
|
+
toanalyze += added
|
160
|
+
end
|
161
|
+
if folder[:opts][:fsnotify].include? :removed
|
162
|
+
toanalyze += removed
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
toanalyze.each do |file|
|
120
167
|
|
121
168
|
if file.start_with?(hostpath)
|
122
169
|
|
@@ -128,7 +175,13 @@ module VagrantPlugins::Fsnotify
|
|
128
175
|
end
|
129
176
|
|
130
177
|
@changes[rel_path] = Time.now.to_i
|
131
|
-
|
178
|
+
if modified.include? file
|
179
|
+
folder[:machine].ui.info("fsnotify: Changed: #{rel_path}")
|
180
|
+
elsif added.include? file
|
181
|
+
folder[:machine].ui.info("fsnotify: Added: #{rel_path}")
|
182
|
+
elsif removed.include? file
|
183
|
+
folder[:machine].ui.info("fsnotify: Removed: #{rel_path}")
|
184
|
+
end
|
132
185
|
|
133
186
|
guestpath = folder[:opts][:override_guestpath] || folder[:opts][:guestpath]
|
134
187
|
guestpath = File.join(guestpath, rel_path)
|
@@ -136,6 +189,9 @@ module VagrantPlugins::Fsnotify
|
|
136
189
|
tosync[folder[:machine]] = [] if !tosync.has_key?(folder[:machine])
|
137
190
|
tosync[folder[:machine]] << guestpath
|
138
191
|
|
192
|
+
if removed.include? file
|
193
|
+
todelete << guestpath
|
194
|
+
end
|
139
195
|
end
|
140
196
|
|
141
197
|
end
|
@@ -143,7 +199,12 @@ module VagrantPlugins::Fsnotify
|
|
143
199
|
end
|
144
200
|
|
145
201
|
tosync.each do |machine, files|
|
146
|
-
machine.
|
202
|
+
touch_flags = get_touch_flags(machine.config.fsnotify.touch)
|
203
|
+
machine.communicate.execute("touch -#{touch_flags} '#{files.join("' '")}'")
|
204
|
+
remove_from_this_machine = files & todelete
|
205
|
+
unless remove_from_this_machine.empty?
|
206
|
+
machine.communicate.execute("rm -rf '#{remove_from_this_machine.join("' '")}'")
|
207
|
+
end
|
147
208
|
end
|
148
209
|
|
149
210
|
rescue => e
|
@@ -163,5 +224,14 @@ module VagrantPlugins::Fsnotify
|
|
163
224
|
|
164
225
|
end
|
165
226
|
|
227
|
+
def get_touch_flags(touch)
|
228
|
+
if touch.include? :modification and not touch.include? :access
|
229
|
+
return "m"
|
230
|
+
elsif not touch.include? :modification and touch.include? :access
|
231
|
+
return "a"
|
232
|
+
else
|
233
|
+
return "am"
|
234
|
+
end
|
235
|
+
end
|
166
236
|
end
|
167
237
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The vagrant-fsnotify plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
if Vagrant::VERSION < "1.7.3"
|
8
|
+
raise <<-ERROR
|
9
|
+
The vagrant-fsnotify plugin is only compatible with Vagrant 1.7.3+. If you can't
|
10
|
+
upgrade, consider installing an old version of vagrant-fsnotify with:
|
11
|
+
$ vagrant plugin install vagrant-fsnotify --plugin-version 0.0.6.
|
12
|
+
ERROR
|
13
|
+
end
|
14
|
+
|
15
|
+
module VagrantPlugins::Fsnotify
|
16
|
+
|
17
|
+
class Config < Vagrant.plugin("2", :config)
|
18
|
+
attr_accessor :touch
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@touch = UNSET_VALUE
|
22
|
+
end
|
23
|
+
|
24
|
+
def finalize!
|
25
|
+
@touch = [:modification, :access] if @touch == UNSET_VALUE
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -4,8 +4,12 @@ rescue LoadError
|
|
4
4
|
raise "The vagrant-fsnotify plugin must be run within Vagrant."
|
5
5
|
end
|
6
6
|
|
7
|
-
if Vagrant::VERSION < "1.
|
8
|
-
raise
|
7
|
+
if Vagrant::VERSION < "1.7.3"
|
8
|
+
raise <<-ERROR
|
9
|
+
The vagrant-fsnotify plugin is only compatible with Vagrant 1.7.3+. If you can't
|
10
|
+
upgrade, consider installing an old version of vagrant-fsnotify with:
|
11
|
+
$ vagrant plugin install vagrant-fsnotify --plugin-version 0.0.6.
|
12
|
+
ERROR
|
9
13
|
end
|
10
14
|
|
11
15
|
module VagrantPlugins::Fsnotify
|
@@ -18,6 +22,11 @@ module VagrantPlugins::Fsnotify
|
|
18
22
|
Command
|
19
23
|
end
|
20
24
|
|
25
|
+
config "fsnotify" do
|
26
|
+
require_relative "config-fsnotify"
|
27
|
+
Config
|
28
|
+
end
|
29
|
+
|
21
30
|
end
|
22
31
|
|
23
32
|
end
|
data/vagrant-fsnotify.gemspec
CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
25
23
|
end
|
metadata
CHANGED
@@ -1,57 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-fsnotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Kohlbecker
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: listen
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.8.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 2.8.0
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- -
|
17
|
+
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
19
|
+
version: '0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
26
|
+
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '0'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '0'
|
55
41
|
description: Use vagrant-fsnotify to forward filesystem change notifications to your
|
56
42
|
Vagrant VM
|
57
43
|
email:
|
@@ -60,7 +46,9 @@ executables: []
|
|
60
46
|
extensions: []
|
61
47
|
extra_rdoc_files: []
|
62
48
|
files:
|
63
|
-
- .gitignore
|
49
|
+
- ".gitignore"
|
50
|
+
- AUTHORS
|
51
|
+
- CHANGELOG.md
|
64
52
|
- Gemfile
|
65
53
|
- LICENSE
|
66
54
|
- README.md
|
@@ -70,6 +58,7 @@ files:
|
|
70
58
|
- bin/setup
|
71
59
|
- lib/vagrant-fsnotify.rb
|
72
60
|
- lib/vagrant-fsnotify/command-fsnotify.rb
|
61
|
+
- lib/vagrant-fsnotify/config-fsnotify.rb
|
73
62
|
- lib/vagrant-fsnotify/plugin.rb
|
74
63
|
- lib/vagrant-fsnotify/version.rb
|
75
64
|
- vagrant-fsnotify.gemspec
|
@@ -77,24 +66,23 @@ homepage: https://github.com/adrienkohlbecker/vagrant-fsnotify
|
|
77
66
|
licenses:
|
78
67
|
- MIT
|
79
68
|
metadata: {}
|
80
|
-
post_install_message:
|
69
|
+
post_install_message:
|
81
70
|
rdoc_options: []
|
82
71
|
require_paths:
|
83
72
|
- lib
|
84
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
74
|
requirements:
|
86
|
-
- -
|
75
|
+
- - ">="
|
87
76
|
- !ruby/object:Gem::Version
|
88
77
|
version: '0'
|
89
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
requirements: []
|
95
|
-
|
96
|
-
|
97
|
-
signing_key:
|
84
|
+
rubygems_version: 3.1.4
|
85
|
+
signing_key:
|
98
86
|
specification_version: 4
|
99
87
|
summary: Forward filesystem change notifications to your Vagrant VM
|
100
88
|
test_files: []
|