Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion embedmd/embedmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package embedmd

import (
"bytes"
"context"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -266,7 +267,7 @@ func TestProcess(t *testing.T) {
if tt.dir != "" {
opts = append(opts, WithBaseDir(tt.dir))
}
err := Process(&out, strings.NewReader(tt.in), opts...)
err := Process(context.Background(), &out, strings.NewReader(tt.in), opts...)
if !eqErr(t, tt.name, err, tt.err) {
return
}
Expand Down
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ package main

import (
"bytes"
"context"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

"github.com/campoy/embedmd/embedmd"
"github.com/campoy/embedmd/v2/embedmd"
"github.com/pmezard/go-difflib/difflib"
)

Expand Down Expand Up @@ -90,11 +91,11 @@ func embed(paths []string, rewrite, doDiff bool) (foundDiff bool, err error) {
return false, fmt.Errorf("error: cannot use -w with standard input")
}
if !doDiff {
return false, embedmd.Process(stdout, stdin)
return false, embedmd.Process(context.Background(), stdout, stdin)
}

var out, in bytes.Buffer
if err := embedmd.Process(&out, io.TeeReader(stdin, &in)); err != nil {
if err := embedmd.Process(context.Background(), &out, io.TeeReader(stdin, &in)); err != nil {
return false, err
}
d, err := diff(in.String(), out.String())
Expand Down Expand Up @@ -147,7 +148,7 @@ func processFile(path string, rewrite, doDiff bool) (foundDiff bool, err error)
defer f.Close()

buf := new(bytes.Buffer)
if err := embedmd.Process(buf, f, embedmd.WithBaseDir(filepath.Dir(path))); err != nil {
if err := embedmd.Process(context.Background(), buf, f, embedmd.WithBaseDir(filepath.Dir(path))); err != nil {
return false, err
}

Expand Down