summaryrefslogtreecommitdiffhomepage
path: root/commands/import_jekyll.go
diff options
context:
space:
mode:
authorCameron Moore <[email protected]>2016-12-26 15:23:20 -0600
committerBjørn Erik Pedersen <[email protected]>2017-03-11 17:52:25 +0100
commitf039e3be9e4a11808508c8cd3043b340deea040f (patch)
treedf3e709fc6321fd2a3e1d23efa2c3512d8ed4a94 /commands/import_jekyll.go
parentddc8cc0082965143a650052a9aa538bac9133481 (diff)
downloadhugo-f039e3be9e4a11808508c8cd3043b340deea040f.tar.gz
hugo-f039e3be9e4a11808508c8cd3043b340deea040f.zip
parser: Refactor frontmatter parser and add tests
Lots of cleanups here: - Refactor InterfaceToConfig and InterfaceToFrontMatter to use io.Writer. - Simplify InterfaceToFrontMatter by wrapping InterfaceToConfig. - Export FrontmatterType since we return it in DetectFrontMatter. - Refactor removeTOMLIdentifier to avoid blindly replacing "+++". - Update HandleJSONMetaData to return an empty map on nil input. - Updates vendored goorgeous package and test for org-mode frontmatter. - Add tests and godoc comments. Coverage for parser package increased from 45.2% to 85.2%.
Diffstat (limited to 'commands/import_jekyll.go')
-rw-r--r--commands/import_jekyll.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go
index 151fffa8a..c33b68f2e 100644
--- a/commands/import_jekyll.go
+++ b/commands/import_jekyll.go
@@ -251,17 +251,13 @@ func createConfigFromJekyll(fs afero.Fs, inpath string, kind string, jekyllConfi
}
kind = parser.FormatSanitize(kind)
- by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind))
+ var buf bytes.Buffer
+ err = parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind), &buf)
if err != nil {
return err
}
- err = helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), bytes.NewReader(by), fs)
- if err != nil {
- return
- }
-
- return nil
+ return helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), &buf, fs)
}
func copyFile(source string, dest string) error {