Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
e4048f21
Commit
e4048f21
authored
Sep 20, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatically create sketchbook directory on 'sketch new' command
Fix #40
parent
2aea290f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
commands/commands_test.go
commands/commands_test.go
+13
-0
commands/sketch/new.go
commands/sketch/new.go
+1
-1
No files found.
commands/commands_test.go
View file @
e4048f21
...
...
@@ -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
)()
...
...
commands/sketch/new.go
View file @
e4048f21
...
...
@@ -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
.
Mkdir
All
();
err
!=
nil
{
formatter
.
PrintError
(
err
,
"Could not create sketch directory."
)
os
.
Exit
(
commands
.
ErrGeneric
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment