Ensure a newline exists at the end of files.

Fixes #42.
This commit is contained in:
Alec Thomas
2017-09-29 21:59:52 +10:00
parent 528bed2b60
commit 573c1d157d
13 changed files with 34 additions and 27 deletions
+4 -1
View File
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/alecthomas/chroma/formatters"
"github.com/alecthomas/chroma/lexers"
@@ -24,12 +25,14 @@ func main() {
fmt.Printf("warning: could not find lexer for %q\n", file)
continue
}
fmt.Printf("%s: ", file)
os.Stdout.Sync()
text, err := ioutil.ReadFile(file)
kingpin.FatalIfError(err, "")
it, err := lexer.Tokenise(nil, string(text))
kingpin.FatalIfError(err, "%s failed to tokenise %q", lexer.Config().Name, file)
err = formatters.NoOp.Format(ioutil.Discard, styles.SwapOff, it)
kingpin.FatalIfError(err, "%s failed to format %q", lexer.Config().Name, file)
fmt.Printf("ok: %q\n", file)
fmt.Printf("ok\n")
}
}