4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/packr/file_system.rb', line 4
def self.bundle(source_paths, output_path, options)
output = output_path && File.expand_path(output_path)
sections = source_paths.map do |source|
path = File.expand_path(source)
relative = relative_path(path, output)
{:code => File.read(path), :source => relative}
end
packed = Packr.pack(sections,
:minify => options[:minify],
:shrink_vars => options[:shrink_vars],
:private => options[:private],
:base62 => options[:base62],
:protect => options[:protect],
:header => options[:header],
:output_file => output
)
source_map = packed.source_map
if output
FileUtils.mkdir_p(File.dirname(output))
File.open(output, 'w') { |f| f.write(packed) }
File.open(source_map.filename, 'w') { |f| f.write(source_map.to_s) }
end
packed
end
|