-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmplnator.go
58 lines (46 loc) · 1.01 KB
/
tmplnator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package tmplnator
import (
"os"
"path/filepath"
"runtime"
l "github.com/Sirupsen/logrus"
"github.com/albertrdixon/tmplnator/backend"
"github.com/spf13/afero"
)
var (
errChan chan error
data *Data
srcFs afero.Fs
destFs afero.Fs
// Backend is the Key/Value store for Data
Backend backend.Backend
// ForceTemp will force all templates to be written to TmpDir if true
ForceTemp = false
// TmpDir is the tmpdir we will use
TmpDir = filepath.Join(os.TempDir(), "T2")
cpus = runtime.NumCPU()
pkg = "tmplnator"
)
func LogLevel(level string) {
lvl, err := l.ParseLevel(level)
if err != nil {
lvl = l.InfoLevel
}
l.SetLevel(lvl)
}
func MemGen(root string) []*File {
initFs(false, true)
l.Debugf("Initialized Source FS: %v", srcFs)
l.Debugf("Initialized Destination FS: %v", destFs)
return generate(root)
}
func RealGen(root string) []*File {
initFs(false, false)
return generate(root)
}
func GetFs() (afero.Fs, afero.Fs) {
return srcFs, destFs
}
func ClearFs() {
srcFs, destFs = nil, nil
}