Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 16, 2021
1 parent d782589 commit 63509bb
Show file tree
Hide file tree
Showing 6 changed files with 461 additions and 616 deletions.
520 changes: 223 additions & 297 deletions chezmoi2/completions/chezmoi2.ps1

Large diffs are not rendered by default.

41 changes: 0 additions & 41 deletions chezmoi2/main_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -51,7 +49,6 @@ func TestScript(t *testing.T) {
"mkhomedir": cmdMkHomeDir,
"mksourcedir": cmdMkSourceDir,
"rmfinalnewline": cmdRmFinalNewline,
"unix2dos": cmdUNIX2DOS,
},
Condition: func(cond string) (bool, error) {
switch cond {
Expand Down Expand Up @@ -379,26 +376,6 @@ func cmdRmFinalNewline(ts *testscript.TestScript, neg bool, args []string) {
}
}

// cmdUNIX2DOS converts files from UNIX line endings to DOS line endings.
func cmdUNIX2DOS(ts *testscript.TestScript, neg bool, args []string) {
if neg {
ts.Fatalf("unsupported: ! unix2dos")
}
if len(args) < 1 {
ts.Fatalf("usage: unix2dos paths...")
}
for _, arg := range args {
filename := ts.MkAbs(arg)
data, err := ioutil.ReadFile(filename)
ts.Check(err)
dosData, err := unix2DOS(data)
ts.Check(err)
if err := ioutil.WriteFile(filename, dosData, 0o666); err != nil {
ts.Fatalf("%s: %v", filename, err)
}
}
}

func prependDirToPath(dir, path string) string {
return strings.Join(append([]string{dir}, filepath.SplitList(path)...), string(os.PathListSeparator))
}
Expand Down Expand Up @@ -490,21 +467,3 @@ func setup(env *testscript.Env) error {

return vfst.NewBuilder().Build(vfs.NewPathFS(vfs.OSFS, env.WorkDir), root)
}

// unix2DOS returns data with UNIX line endings converted to DOS line endings.
func unix2DOS(data []byte) ([]byte, error) {
sb := strings.Builder{}
s := bufio.NewScanner(bytes.NewReader(data))
for s.Scan() {
if _, err := sb.Write(s.Bytes()); err != nil {
return nil, err
}
if _, err := sb.WriteString("\r\n"); err != nil {
return nil, err
}
}
if err := s.Err(); err != nil {
return nil, err
}
return []byte(sb.String()), nil
}
Loading

0 comments on commit 63509bb

Please sign in to comment.