-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
71 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package constants | ||
|
||
const DEV_DEPS_SECTION = "devDependencies" | ||
const DEV_DEPS_INSTALLATION_PARAM = "-D" | ||
const SCRIPTS_SECTION = "scripts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,9 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
func CreateFolderOrFileIfNotExists(path string, isFolder bool) { | ||
exists := CheckIfExists(path) | ||
|
||
"github.com/RaulCatalinas/HuskyBC/internal/enums" | ||
errorMessages "github.com/RaulCatalinas/HuskyBC/internal/error_messages" | ||
) | ||
|
||
func createFolder(name string) { | ||
os.Mkdir(name, 0750) | ||
|
||
message := "Created folder " + name | ||
|
||
WriteMessage(WriteMessageProps{ | ||
Type: enums.MessageTypeInfo, | ||
Message: message, | ||
}) | ||
} | ||
|
||
func createFile(name string) { | ||
os.NewFile(0750, name) | ||
|
||
message := "Created file " + name | ||
|
||
WriteMessage(WriteMessageProps{ | ||
Type: enums.MessageTypeSuccess, | ||
Message: message, | ||
}) | ||
} | ||
|
||
func CheckinFolderOrFile(path string, isFolder bool) { | ||
_, err := os.Stat(path) | ||
|
||
if err != nil { | ||
if isFolder { | ||
createFolder(path) | ||
} else { | ||
createFile(path) | ||
} | ||
|
||
WriteMessage(WriteMessageProps{ | ||
Type: enums.MessageTypeError, | ||
Message: errorMessages.PROCESS_ERROR_MESSAGES[enums.CheckingFolderOrFileError], | ||
}) | ||
|
||
if os.IsNotExist(err) { | ||
errorMessage := errorMessages.FILE_ERROR_MESSAGES[enums.NotFoundError] | ||
|
||
WriteMessage(WriteMessageProps{ | ||
Type: enums.MessageTypeError, | ||
Message: strings.Replace(errorMessage, "{fileName}", path, -1), | ||
}) | ||
} else { | ||
os.Exit(0) | ||
} | ||
if !exists { | ||
createFolderOrFile(path, isFolder) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters