1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Add a command-line option for writing files in binary mode on Windows.

This commit is contained in:
Nathan Weizenbaum 2010-01-23 12:52:30 -08:00
parent ea814b0bfa
commit 518ba4cc2a

View file

@ -1,5 +1,6 @@
require 'optparse'
require 'fileutils'
require 'rbconfig'
module Haml
# This module handles the various Haml executables (`haml`, `sass`, `css2sass`, etc).
@ -67,6 +68,12 @@ module Haml
@options[:trace] = true
end
if RbConfig::CONFIG['host_os'] =~ /mswin|windows/i
opts.on('--unix-newlines', 'Use Unix-style newlines in written files.') do
@options[:unix_newlines] = true
end
end
opts.on_tail("-?", "-h", "--help", "Show this message") do
puts opts
exit
@ -105,6 +112,7 @@ module Haml
def open_file(filename, flag = 'r')
return if filename.nil?
flag = 'wb' if @options[:unix_newlines] && flag == 'w'
File.open(filename, flag)
end
end