Skip to content

Commit e38e7a1

Browse files
wrote tests for packages "version" and "args", and update code for creating Makefile
1 parent 5490645 commit e38e7a1

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,36 @@ PROJECT_NAME = create-project-struct
22
PROJECT_PATH = cmd/$(PROJECT_NAME).go
33
PROGRAM_NAME = cps
44

5+
.PHONE: run
56
run:
67
go run $(PROJECT_PATH)
78

9+
10+
.PHONE: build
811
build:
912
go build -o $(PROGRAM_NAME) $(PROJECT_PATH)
1013

14+
15+
.PHONY: tests
16+
tests:
17+
go test ./...
18+
19+
20+
.PHONE: exec
1121
exec:
1222
make build && sudo mv cps /usr/local/bin/cps
1323

24+
25+
.PHONE: rm-program
1426
rm-program:
1527
sudo rm /usr/local/bin/cps
1628

29+
30+
.PHONE: test
1731
test:
1832
sudo make rm-program && make exec
1933

34+
35+
.PHONE: clear
2036
clear:
2137
sh ./script/clear.sh

internal/app/file/file.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ func (fl File) GenerateMakefile(projectName string, isCurrentDir bool) error {
8787
content := fmt.Sprintf(
8888
"PROJECT_NAME = %s\n"+
8989
"PROJECT_PATH = cmd/$(PROJECT_NAME).go\n"+
90-
"run:\n\tgo run $(PROJECT_PATH)\n\n"+
91-
"build:\n\tgo build -o bin/$(PROGRAM_NAME) $(PROJECT_PATH)\n\n"+
92-
"lint:\n\tgolangci-lint run",
90+
".PHONY:run\nrun:\n\tgo run $(PROJECT_PATH)\n\n"+
91+
".PHONY:build\nbuild:\n\tgo build -o bin/$(PROGRAM_NAME) $(PROJECT_PATH)\n\n"+
92+
".PHONY:test\ntest:\n\tgo test ./...\n\n"+
93+
".PHONY:lint\nlint:\n\tgolangci-lint run",
9394
projectName,
9495
)
9596

internal/pkg/git/git.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package git
2+
3+
import (
4+
"os/exec"
5+
)
6+
7+
func CreateLocalGitRepository() error {
8+
cmd := exec.Command("git", "init")
9+
10+
if err := cmd.Run(); err != nil {
11+
return err
12+
}
13+
14+
return nil
15+
}

0 commit comments

Comments
 (0)