tangled
alpha
login
or
join now
anirudh.fi
/
vite
5
fork
atom
fast and minimal static site generator
ssg
5
fork
atom
overview
issues
1
pulls
pipelines
Move util to fileutil
anirudh.fi
11 months ago
a64168ba
39b17ddd
verified
This commit was signed with the committer's
known signature
.
anirudh.fi
SSH Key Fingerprint:
SHA256:cz35vdbiWEzCNEfuL9fMC2JVIhtXavXBHrRjv8gxpAk=
+22
-29
5 changed files
expand all
collapse all
unified
split
commands
build.go
fileutil
copy.go
rmall.go
formats
anything.go
util
run.go
+19
-3
commands/build.go
reviewed
···
3
3
import (
4
4
"fmt"
5
5
"os"
6
6
+
"os/exec"
6
7
"path/filepath"
7
8
"sort"
8
9
"strings"
···
10
11
11
12
"tangled.sh/icyphox.sh/vite/atom"
12
13
"tangled.sh/icyphox.sh/vite/config"
14
14
+
util "tangled.sh/icyphox.sh/vite/fileutil"
13
15
"tangled.sh/icyphox.sh/vite/formats"
14
16
"tangled.sh/icyphox.sh/vite/formats/markdown"
15
17
"tangled.sh/icyphox.sh/vite/formats/yaml"
16
18
"tangled.sh/icyphox.sh/vite/types"
17
17
-
"tangled.sh/icyphox.sh/vite/util"
18
19
)
19
20
20
21
type Dir struct {
···
224
225
return nil
225
226
}
226
227
228
228
+
func runCmd(cmd string, args ...string) error {
229
229
+
parts := strings.Fields(cmd)
230
230
+
if len(parts) == 0 {
231
231
+
return fmt.Errorf("error: is there an empty command?")
232
232
+
}
233
233
+
234
234
+
execCmd := exec.Command(parts[0], parts[1:]...)
235
235
+
236
236
+
output, err := execCmd.CombinedOutput()
237
237
+
if err != nil {
238
238
+
return fmt.Errorf("error: command %q failed with %v: %s", cmd, err, output)
239
239
+
}
240
240
+
return nil
241
241
+
}
242
242
+
227
243
func postBuild() error {
228
244
for _, cmd := range config.Config.PostBuild {
229
245
fmt.Println("vite: running post-build command:", cmd)
230
230
-
if err := util.RunCmd(cmd); err != nil {
246
246
+
if err := runCmd(cmd); err != nil {
231
247
return err
232
248
}
233
249
}
···
237
253
func preBuild() error {
238
254
for _, cmd := range config.Config.PreBuild {
239
255
fmt.Println("vite: running pre-build command:", cmd)
240
240
-
if err := util.RunCmd(cmd); err != nil {
256
256
+
if err := runCmd(cmd); err != nil {
241
257
return err
242
258
}
243
259
}
+1
-1
formats/anything.go
reviewed
···
3
3
import (
4
4
"path/filepath"
5
5
6
6
-
"tangled.sh/icyphox.sh/vite/util"
6
6
+
util "tangled.sh/icyphox.sh/vite/fileutil"
7
7
)
8
8
9
9
// Anything is a stub format for unrecognized files
+1
-1
util/copy.go
fileutil/copy.go
reviewed
···
1
1
-
package util
1
1
+
package fileutil
2
2
3
3
import (
4
4
"fmt"
+1
-1
util/rmall.go
fileutil/rmall.go
reviewed
···
1
1
-
package util
1
1
+
package fileutil
2
2
3
3
import (
4
4
"os"
-23
util/run.go
reviewed
···
1
1
-
package util
2
2
-
3
3
-
import (
4
4
-
"fmt"
5
5
-
"os/exec"
6
6
-
"strings"
7
7
-
)
8
8
-
9
9
-
func RunCmd(cmd string, args ...string) error {
10
10
-
// Split the command into the executable and its arguments
11
11
-
parts := strings.Fields(cmd)
12
12
-
if len(parts) == 0 {
13
13
-
return fmt.Errorf("error: is there an empty command?")
14
14
-
}
15
15
-
16
16
-
execCmd := exec.Command(parts[0], parts[1:]...)
17
17
-
18
18
-
output, err := execCmd.CombinedOutput()
19
19
-
if err != nil {
20
20
-
return fmt.Errorf("error: command %q failed with %v: %s", cmd, err, output)
21
21
-
}
22
22
-
return nil
23
23
-
}