Skip to content

Commit

Permalink
update for sourcemap changes in libSass
Browse files Browse the repository at this point in the history
  • Loading branch information
drewwells committed Nov 1, 2016
1 parent 7160c0b commit 86ddc18
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,17 @@ func (b *Build) Close() error {

var inputFileTypes = []string{".scss", ".sass"}

func (b *BuildArgs) getOut(path string) (io.WriteCloser, io.WriteCloser, string, error) {
func (b *BuildArgs) getOut(path string) (io.WriteCloser, string, string, error) {

var (
out io.WriteCloser
)
if b == nil {
return nil, nil, "", errors.New("build args is nil")
return nil, "", "", errors.New("build args is nil")
}
if len(b.BuildDir) == 0 {
out = os.Stdout
return out, nil, "", nil
return out, "", "", nil
}
rel := relative(b.paths, path)
filename := updateFileOutputType(filepath.Base(path))
Expand All @@ -205,16 +205,16 @@ func (b *BuildArgs) getOut(path string) (io.WriteCloser, io.WriteCloser, string,
// FIXME: do this once per Build instead of every file
err := os.MkdirAll(dir, 0755)
if err != nil {
return nil, nil, "", fmt.Errorf("Failed to create directory: %s",
return nil, "", "", fmt.Errorf("Failed to create directory: %s",
dir)
}
out, err = os.Create(name)
if err != nil {
return nil, nil, "", err
return nil, "", "", err
}
var smap *os.File
var smap string
if b.SourceMap {
smap, err = os.Create(name + ".map")
smap = name + ".map"
}

return out, smap, dir, err
Expand Down Expand Up @@ -250,7 +250,7 @@ func LoadAndBuild(path string, gba *BuildArgs, pMap *SafePartialMap) error {
}

// FromBuildArgs creates a compiler from BuildArgs
func FromBuildArgs(dst io.Writer, dstmap io.Writer, src io.Reader, gba *BuildArgs) (libsass.Compiler, error) {
func FromBuildArgs(dst io.Writer, dstmap string, src io.Reader, gba *BuildArgs) (libsass.Compiler, error) {
if gba == nil {
return libsass.New(dst, src)
}
Expand All @@ -275,7 +275,7 @@ func FromBuildArgs(dst io.Writer, dstmap io.Writer, src io.Reader, gba *BuildArg
return comp, err
}

func loadAndBuild(sassFile string, gba *BuildArgs, partialMap *SafePartialMap, out io.WriteCloser, sout io.WriteCloser, buildDir string) error {
func loadAndBuild(sassFile string, gba *BuildArgs, partialMap *SafePartialMap, out io.WriteCloser, srcmap string, buildDir string) error {
defer func() {
// BuildDir lets us know if we should closer out. If no buildDir,
// specified out == os.Stdout and do not close. If buildDir != "",
Expand All @@ -284,7 +284,7 @@ func loadAndBuild(sassFile string, gba *BuildArgs, partialMap *SafePartialMap, o
// them could be race unsafe.
if len(buildDir) > 0 {
out.Close()
sout.Close()
// sout.Close()
}
}()

Expand All @@ -305,7 +305,7 @@ func loadAndBuild(sassFile string, gba *BuildArgs, partialMap *SafePartialMap, o
libsass.FontDir(gba.Font),
libsass.ImgBuildDir(gba.Gen),
libsass.IncludePaths(gba.Includes),
libsass.SourceMap(gba.SourceMap, sout),
libsass.SourceMap(gba.SourceMap, srcmap),
)

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func init() {
}

func TestFromBuildArgs(t *testing.T) {
_, err := FromBuildArgs(nil, nil, nil, nil)
_, err := FromBuildArgs(nil, "", nil, nil)
if err != nil {
t.Fatal(err)
}

_, err = FromBuildArgs(nil, nil, nil, &BuildArgs{})
_, err = FromBuildArgs(nil, "", nil, &BuildArgs{})
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestBuild_error(t *testing.T) {
_, w, _ := os.Pipe()

err := loadAndBuild("test/sass/error.scss", &BuildArgs{},
NewPartialMap(), w, nil, "")
NewPartialMap(), w, "", "")

if err == nil {
t.Fatal("no error thrown")
Expand All @@ -277,7 +277,7 @@ func TestBuild_args(t *testing.T) {
}

err := loadAndBuild("test/sass/file.scss", bArgs,
NewPartialMap(), w, nil, "")
NewPartialMap(), w, "", "")
if err != nil {
t.Fatal(err)
}
Expand All @@ -302,7 +302,7 @@ func TestBuild_comply(t *testing.T) {
&BuildArgs{
Includes: []string{"test"},
},
NewPartialMap(), w, nil, "")
NewPartialMap(), w, "", "")
w.Close()
bs, err := ioutil.ReadAll(r)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func HTTPHandler(gba *BuildArgs, httpPath string) func(w http.ResponseWriter, r
}
defer r.Body.Close()

comp, err := FromBuildArgs(&pout, nil, r.Body, gba)
comp, err := FromBuildArgs(&pout, "", r.Body, gba)
if err != nil {
resp.Contents = ""
return
Expand Down
2 changes: 1 addition & 1 deletion wt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func run(pMap *wt.SafePartialMap, gba *wt.BuildArgs) {
log.Println("Reading from stdin, -h for help")
out := os.Stdout
in := os.Stdin
comp, err := wt.FromBuildArgs(out, nil, in, gba)
comp, err := wt.FromBuildArgs(out, "", in, gba)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 86ddc18

Please sign in to comment.