Commit e4048f21 authored by Cristian Maglie's avatar Cristian Maglie

Automatically create sketchbook directory on 'sketch new' command

Fix #40
parent 2aea290f
......@@ -137,6 +137,9 @@ func makeTempSketchbookDir(t *testing.T) func() {
require.NoError(t, err, "making temporary staging dir")
os.Setenv("ARDUINO_SKETCHBOOK_DIR", tmp.String())
currSketchbookDir = tmp
err = tmp.RemoveAll() // To test if the sketchbook dir is automatically created
require.NoError(t, err)
fmt.Printf("ARDUINO_SKETCHBOOK_DIR = %s\n", os.Getenv("ARDUINO_SKETCHBOOK_DIR"))
return func() {
os.Unsetenv("ARDUINO_SKETCHBOOK_DIR")
......@@ -212,6 +215,16 @@ func TestUserLibs(t *testing.T) {
require.Contains(t, string(d), "MyLibWithWrongVersion")
}
func TestSketchCommands(t *testing.T) {
defer makeTempDataDir(t)()
defer makeTempSketchbookDir(t)()
//var d []byte
var exitCode int
exitCode, _ = executeWithArgs(t, "sketch", "new", "Test")
require.Zero(t, exitCode, "exit code")
}
func TestLibDownloadAndInstall(t *testing.T) {
defer makeTempDataDir(t)()
defer makeTempSketchbookDir(t)()
......
......@@ -47,7 +47,7 @@ void loop() {
func runNewCommand(cmd *cobra.Command, args []string) {
sketchDir := commands.Config.SketchbookDir.Join(args[0])
if err := sketchDir.Mkdir(); err != nil {
if err := sketchDir.MkdirAll(); err != nil {
formatter.PrintError(err, "Could not create sketch directory.")
os.Exit(commands.ErrGeneric)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment