custom path support
This commit is contained in:
parent
0fd83277d9
commit
ef6f05d84c
|
@ -178,7 +178,7 @@ A Go build system with file watchers, output streams and live reload. Run, build
|
|||
|
||||
##### Milestone 1.1
|
||||
- [ ] Testing on windows
|
||||
- [ ] Custom paths for the commands fast/add
|
||||
- [x] Custom paths for the commands fast/add
|
||||
- [ ] Save output on a file
|
||||
- [ ] Enable the fields Before/After
|
||||
- [ ] Web panel - **Maybe**
|
||||
|
|
2
main.go
2
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
r "github.com/tockins/realize/realize"
|
||||
_ "github.com/tockins/realize/server"
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -61,6 +62,7 @@ func main() {
|
|||
Name: "fast",
|
||||
Usage: "Build and watch file changes for a single project without any config file",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{Name: "path", Aliases: []string{"b"}, Value: "", Usage: "Project base path"},
|
||||
&cli.BoolFlag{Name: "build", Value: false, Usage: "Enables the build"},
|
||||
&cli.BoolFlag{Name: "no-run", Usage: "Disables the run"},
|
||||
&cli.BoolFlag{Name: "no-bin", Usage: "Disables the installation"},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package realize
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
|
@ -78,7 +79,11 @@ func (p *Project) watching() {
|
|||
}
|
||||
defer end()
|
||||
|
||||
p.walks(watcher)
|
||||
err = p.walks(watcher)
|
||||
if err != nil {
|
||||
fmt.Println(pname(p.Name, 1), ":", Red(err.Error()))
|
||||
return
|
||||
}
|
||||
go routines(p, channel, &wr)
|
||||
p.reload = time.Now().Truncate(time.Second)
|
||||
|
||||
|
@ -189,7 +194,7 @@ func (p *Project) test(path string) error {
|
|||
}
|
||||
|
||||
// Walks the file tree of a project
|
||||
func (p *Project) walks(watcher *fsnotify.Watcher) {
|
||||
func (p *Project) walks(watcher *fsnotify.Watcher) error {
|
||||
var files, folders int64
|
||||
wd, _ := os.Getwd()
|
||||
|
||||
|
@ -226,9 +231,12 @@ func (p *Project) walks(watcher *fsnotify.Watcher) {
|
|||
if p.Path == "." || p.Path == "/" {
|
||||
p.base = wd
|
||||
p.Path = WorkingDir()
|
||||
} else if filepath.IsAbs(p.Path) {
|
||||
p.base = p.Path
|
||||
} else {
|
||||
p.base = filepath.Join(wd, p.Path)
|
||||
}
|
||||
|
||||
for _, dir := range p.Watcher.Paths {
|
||||
base := filepath.Join(p.base, dir)
|
||||
if _, err := os.Stat(base); err == nil {
|
||||
|
@ -236,10 +244,11 @@ func (p *Project) walks(watcher *fsnotify.Watcher) {
|
|||
log.Println(Red(err.Error()))
|
||||
}
|
||||
} else {
|
||||
fmt.Println(pname(p.Name, 1), ":\t", Red(base+" path doesn't exist"))
|
||||
return errors.New(base + " path doesn't exist")
|
||||
}
|
||||
}
|
||||
fmt.Println(Red("Watching: "), pname(p.Name, 1), Magenta(files), "file/s", Magenta(folders), "folder/s")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ignore validates a path
|
||||
|
|
Loading…
Reference in New Issue