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:
parent
ea814b0bfa
commit
518ba4cc2a
1 changed files with 8 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
require 'rbconfig'
|
||||||
|
|
||||||
module Haml
|
module Haml
|
||||||
# This module handles the various Haml executables (`haml`, `sass`, `css2sass`, etc).
|
# This module handles the various Haml executables (`haml`, `sass`, `css2sass`, etc).
|
||||||
|
@ -67,6 +68,12 @@ module Haml
|
||||||
@options[:trace] = true
|
@options[:trace] = true
|
||||||
end
|
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
|
opts.on_tail("-?", "-h", "--help", "Show this message") do
|
||||||
puts opts
|
puts opts
|
||||||
exit
|
exit
|
||||||
|
@ -105,6 +112,7 @@ module Haml
|
||||||
|
|
||||||
def open_file(filename, flag = 'r')
|
def open_file(filename, flag = 'r')
|
||||||
return if filename.nil?
|
return if filename.nil?
|
||||||
|
flag = 'wb' if @options[:unix_newlines] && flag == 'w'
|
||||||
File.open(filename, flag)
|
File.open(filename, flag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue