Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna committed Apr 9, 2019
1 parent 6f1f815 commit f2bfa63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*_fmt.jl
23 changes: 11 additions & 12 deletions src/JLFmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,21 @@ function format_file(filename::String, indent_size, print_width; overwrite=false
if ext != ".jl"
throw(ArgumentError("$filename must be a Julia (.jl) source file"))
end
str = read(filename)
str = read(filename) |> String
try
fmtstr = format(str, indent_size=indent_size, print_width=print_width)
catch
ErrorException("""
An error occured formatting $filename. :-(
Please file an issue at https://github.com/domluna/JLFmt.jl/issues
with a link to a gist containing the contents of the file. A gist
can be created at https://gist.github.com/.
""")
str = format(str, indent_size=indent_size, print_width=print_width)
catch e
throw(ErrorException("""
An error occured formatting $filename. :-(
Please file an issue at https://github.com/domluna/JLFmt.jl/issues
with a link to a gist containing the contents of the file. A gist
can be created at https://gist.github.com/."""))
end

if overwrite
write(filename, fmtstr)
write(filename, str)
else
write(path * "_fmt" * ext, fmtstr)
write(path * "_fmt" * ext, str)
end
end

0 comments on commit f2bfa63

Please sign in to comment.