lib/texture_packer/cli.rb in texture_packer-1.5.0 vs lib/texture_packer/cli.rb in texture_packer-1.6.1

- old
+ new

@@ -37,25 +37,25 @@ end end def create_packer split_type = case - when File.exists?('packed_m.css') ; TexturePacker::SPLIT_BY_MOBILE - when File.exists?('packed_tw.css') ; TexturePacker::SPLIT_I18N - else ; nil + when File.exist?('packed_tw_m.css') ; TexturePacker::SPLIT_BY_I18N_AND_MOBILE + when File.exist?('packed_m.css') ; TexturePacker::SPLIT_BY_MOBILE + when File.exist?('packed_tw.css') ; TexturePacker::SPLIT_I18N end # 由路徑計算 class 名字 - dir_name = File.expand_path(Dir.pwd).gsub(/.*\/Texture-Packer\/.*?\/(.*)/, '\1') + dir_name = File.expand_path(Dir.pwd).gsub(%r{.*/Texture-Packer/.*?/(.*)}, '\1') content = output_paths_mapping.map{|_, path| File.read("#{path}.css") }.join return TexturePacker.new(dir_name, output_paths_mapping, content, split_type) end def output_paths_mapping @output_paths_mapping ||= begin - Dir['*.css'].map do |path| + Dir['*.css'].sort.map do |path| name = File.basename(path, '.css') next [name[/packed_(.*)/, 1], name] end.to_h end end @@ -80,15 +80,13 @@ FileUtils.cp("#{path}-fs8.png", img_path.join("#{path.sub('packed', packer.base_dir_name)}.png")) end end def exec_cmd(*args) - begin - puts args.join(' ') - puts system(*args) - rescue => e - puts e - end + puts args.join(' ') + puts system(*args) + rescue => e + puts e end def write_to_file(path, content) puts "output: #{path} #{File.write(path, content)} bytes" end