realize files moved in .realize hidden dir
This commit is contained in:
parent
e6c821ada4
commit
1148047438
|
@ -17,7 +17,6 @@ const (
|
|||
config = "realize.yaml"
|
||||
output = "outputs.log"
|
||||
log = "logs.log"
|
||||
err = "errors.log"
|
||||
host = "localhost"
|
||||
port = 5000
|
||||
server = true
|
||||
|
|
|
@ -3,6 +3,7 @@ package settings
|
|||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Scan return a byte stream of a given file
|
||||
|
@ -23,7 +24,13 @@ func (s Settings) Write(name string, data []byte) error {
|
|||
}
|
||||
|
||||
// Create a new file and return its pointer
|
||||
func (s Settings) Create(file string) *os.File {
|
||||
func (s Settings) Create(path string, name string) *os.File {
|
||||
var file string
|
||||
if _, err := os.Stat(".realize/"); err == nil {
|
||||
file = filepath.Join(path, ".realize/", name)
|
||||
} else {
|
||||
file = filepath.Join(path, name)
|
||||
}
|
||||
out, err := os.OpenFile(file, os.O_APPEND|os.O_WRONLY|os.O_CREATE|os.O_SYNC, 0655)
|
||||
s.Validate(err)
|
||||
return out
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package settings
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Settings struct {
|
||||
|
@ -51,7 +50,9 @@ func (s *Settings) Record(out interface{}) error {
|
|||
return err
|
||||
}
|
||||
if _, err := os.Stat(".realize/"); os.IsNotExist(err) {
|
||||
os.Mkdir(".realize", 0770)
|
||||
if err = os.Mkdir(".realize/", 0770); err != nil {
|
||||
return s.Write(s.Resources.Config, y)
|
||||
}
|
||||
}
|
||||
return s.Write(".realize/"+s.Resources.Config, y)
|
||||
}
|
||||
|
|
|
@ -81,8 +81,7 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
|||
log.Println(p.pname(p.Name, 3), ":", p.Blue.Regular(output.Text()))
|
||||
}
|
||||
if p.File.Streams {
|
||||
path := filepath.Join(p.base, p.Resources.Output)
|
||||
f := p.Create(path)
|
||||
f := p.Create(p.base, p.parent.Resources.Output)
|
||||
t := time.Now()
|
||||
if _, err := f.WriteString(t.Format("2006-01-02 15:04:05") + " : " + output.Text() + "\r\n"); err != nil {
|
||||
p.Fatal(err, "")
|
||||
|
|
|
@ -25,7 +25,6 @@ func (p *Project) watching() {
|
|||
defer func() {
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalln(p.pname(p.Name, 2), ":", p.Red.Bold(err.Error()))
|
||||
return
|
||||
|
@ -312,8 +311,7 @@ func (p *Project) print(t string, o BufferOut, msg string, stream string) {
|
|||
case "out":
|
||||
p.Buffer.StdOut = append(p.Buffer.StdOut, o)
|
||||
if p.File.Streams {
|
||||
path := filepath.Join(p.base, p.Resources.Output)
|
||||
f := p.Create(path)
|
||||
f := p.Create(p.base, p.parent.Resources.Output)
|
||||
t := time.Now()
|
||||
if _, err := f.WriteString(t.Format("2006-01-02 15:04:05") + " : " + o.Text + "\r\n"); err != nil {
|
||||
p.Fatal(err, "")
|
||||
|
@ -322,8 +320,7 @@ func (p *Project) print(t string, o BufferOut, msg string, stream string) {
|
|||
case "log":
|
||||
p.Buffer.StdLog = append(p.Buffer.StdLog, o)
|
||||
if p.File.Logs {
|
||||
path := filepath.Join(p.base, p.Resources.Log)
|
||||
f := p.Create(path)
|
||||
f := p.Create(p.base, p.parent.Resources.Log)
|
||||
t := time.Now()
|
||||
if _, err := f.WriteString(t.Format("2006-01-02 15:04:05") + " : " + o.Text + "\r\n"); err != nil {
|
||||
p.Fatal(err, "")
|
||||
|
@ -332,8 +329,7 @@ func (p *Project) print(t string, o BufferOut, msg string, stream string) {
|
|||
case "error":
|
||||
p.Buffer.StdErr = append(p.Buffer.StdErr, o)
|
||||
if p.File.Errors {
|
||||
path := filepath.Join(p.base, p.Resources.Log)
|
||||
f := p.Create(path)
|
||||
f := p.Create(p.base, p.parent.Resources.Log)
|
||||
t := time.Now()
|
||||
if _, err := f.WriteString(t.Format("2006-01-02 15:04:05") + " : " + o.Text + "\r\n"); err != nil {
|
||||
p.Fatal(err, "")
|
||||
|
|
Loading…
Reference in New Issue