1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 04:17:03 +00:00

Organising kataras/go-fs. No api changes for these changes don't worry. See previous commit's description for more info.

Former-commit-id: 8af960e5e4e5f7c8816140ac912328b9c524370b
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-03-01 19:17:32 +02:00
parent 57aea4aa75
commit a6fc0072ff
8 changed files with 392 additions and 74 deletions

View File

@@ -7,7 +7,6 @@ import (
"strings"
"github.com/kataras/cli"
"github.com/kataras/go-fs"
"github.com/skratchdot/open-golang/open"
)
@@ -30,6 +29,14 @@ var (
}
)
// DirectoryExists returns true if a directory(or file) exists, otherwise false
func DirectoryExists(dir string) bool {
if _, err := os.Stat(dir); os.IsNotExist(err) {
return false
}
return true
}
// dir returns the supposed local directory for this project
func (p project) dir() string {
return join(getGoPath(), p.remote)
@@ -41,11 +48,12 @@ func (p project) mainfile() string {
func (p project) download() {
// first, check if the repo exists locally in gopath
if fs.DirectoryExists(p.dir()) {
if DirectoryExists(p.dir()) {
return
}
app.Printf("Downloading... ")
finish := fs.ShowIndicator(cli.Output, false)
finish := cli.ShowIndicator(false)
defer func() {
@@ -72,7 +80,7 @@ func (p project) run() {
// the source and change the import paths from there too
// so here just let run and watch it
mainFile := p.mainfile()
if !fs.DirectoryExists(mainFile) { // or file exists, same thing
if !DirectoryExists(mainFile) { // or file exists, same thing
p.download()
}
installedDir := p.dir()