save-and-run

command module
v0.0.0-...-af18fb0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

save-and-run

Idea for alternative to wk-j/vscode-save-and-run,
I use vim, so I don't like .vscode/.
Please contribute and feedback issues. I am beginner of Go.

⚠ this idea is not perfect.

How many files can be watched at once? There are OS-specific limits as to how many watches can be created: Linux: /proc/sys/fs/inotify/max_user_watches contains the limit, reaching this limit results in a "no space left on device" error. BSD / OSX: sysctl variables "kern.maxfiles" and "kern.maxfilesperproc", reaching these limits results in a "too many open files" error.
GitHub - fsnotify/fsnotify: Cross-platform file system notifications for Go.

and not yet testing, and not checked working detail.

go get github.com/kis9a/save-and-run

Command

$ .save-and-run -h

  -c string
        config file path (default "~/.saveAndRun.json")
  -d    display detail logs
  -m    display path match example

Configuration

[ Priority ]

1 -c someName # flag argument
2 ./.saveAndRun.json # current directory .saveAndRun.json
3 ~/.saveAndRun.json # home directory .saveAndRun.json

{
  "saveAndRun": [
    {
      "base": "~/dev/any/static",
      "commands": [
        {
          "match": "views/*/pc/*.scss",
          "cmd": "node-sass general.scss -o dist/scss/${filename}"
        },
        {
          "match": "views/**.html",
          "cmd": "minify html -o $BASE/dist/"
        }
      ]
    }
  ]
}

Match example

Used GitHub - gobwas/glob: Go glob to judge isMatch.

w := tabwriter.NewWriter(os.Stdout, 1, 1, 1, ' ', 0)
fmt.Fprintln(w, "pattern", "\t", "path", "\t", "truth")
displayMatch := func(match string, path string) {
  g := glob.MustCompile(match, '/')
  fmt.Fprintln(w, match, "\t", path, "\t", g.Match(path))
}
displayMatch("*.js", "a.js")             // true
displayMatch("{a,b,c}.js", "a.js")       // true
displayMatch("[a-c].js", "a.js")         // true
displayMatch("[!a-c].js", "d.js")        // true
displayMatch("**.js", "a/b.js")          // true
displayMatch("?????at.js", "12345at.js") // true
displayMatch("*/*.js", "a/b.js")         // true
displayMatch("a/*.js", "a/b.js")         // true
displayMatch("a/**.js", "a/b.js")        // true
displayMatch("*.js", "a/b.js")           // false
displayMatch("{a,b,c}.js", "d.js")       // false
displayMatch("[a-c].js", "d.js")         // false
displayMatch("[1-8].js", "9.js")         // false
displayMatch("b/*.js", "a/b.js")         // false
displayMatch("a/**/*.js", "a/b.js")      // false
w.Flush()

Placeholder Tokens

${cwd} - current working directory
${home} - home directory.
${filePath} - matched filepath.
${fileDirpath} - matched filepath directory path.
${fileDirname} - matched filepath directory name.
${base} - matched file base directory.
${basename} - matched file base directory name.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL