18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/dato/cli.rb', line 18
def dump
config_file = File.expand_path(options[:config])
watch_mode = options[:watch]
preview_mode = options[:preview]
client = Dato::Site::Client.new(
options[:token],
environment: options[:environment],
extra_headers: {
"X-Reason" => "dump",
"X-SSG" => Dump::SsgDetector.new(Dir.pwd).detect,
},
)
loader = Dato::Local::Loader.new(client, preview_mode)
print "Fetching content from DatoCMS... "
loader.load
if watch_mode
semaphore = Mutex.new
thread_safe_dump(semaphore, config_file, client, preview_mode, loader)
loader.watch do
thread_safe_dump(semaphore, config_file, client, preview_mode, loader)
end
watch_config_file(config_file) do
thread_safe_dump(semaphore, config_file, client, preview_mode, loader)
end
sleep
else
Dump::Runner.new(config_file, client, preview_mode, loader).run
end
end
|