@@ -34,16 +34,17 @@ function ensurePort(port) {
34
34
35
35
const listPorts = ( args ) => {
36
36
const board = new Board ( )
37
- board . listPorts ( )
37
+ return board . listPorts ( )
38
38
. then ( ( ports ) => {
39
39
log ( 'available ports' , ports )
40
+ return Promise . resolve ( )
40
41
} )
41
42
}
42
43
43
44
const listFiles = ( args , port ) => {
44
45
ensurePort ( port )
45
46
const board = new Board ( )
46
- board . open ( port )
47
+ return board . open ( port )
47
48
. then ( async ( ) => {
48
49
const folder = args [ 0 ] || '/'
49
50
try {
@@ -53,20 +54,22 @@ const listFiles = (args, port) => {
53
54
log ( 'error' , e )
54
55
}
55
56
board . close ( )
57
+ return Promise . resolve ( )
56
58
} )
57
59
}
58
60
59
61
const executeString = ( args , port , dataConsumer ) => {
60
62
ensurePort ( port )
61
63
const board = new Board ( )
62
64
const code = args [ 0 ] || ''
63
- board . open ( port )
65
+ return board . open ( port )
64
66
. then ( ( ) => board . enter_raw_repl ( ) )
65
67
. then ( ( ) => board . exec_raw ( { command : code , data_consumer : dataConsumer } ) )
66
68
. then ( async ( out ) => {
67
69
await board . exit_raw_repl ( )
68
70
await board . close ( )
69
71
log ( out )
72
+ return Promise . resolve ( )
70
73
} )
71
74
. catch ( ( err ) => {
72
75
log ( 'error' , err )
@@ -80,7 +83,7 @@ const executeFile = (args, port, dataConsumer) => {
80
83
const board = new Board ( )
81
84
const filename = args [ 0 ] || ''
82
85
const consumer = dataConsumer || function ( ) { }
83
- board . open ( port )
86
+ return board . open ( port )
84
87
. then ( async ( ) => {
85
88
try {
86
89
const out = await board . execfile ( filename , consumer )
@@ -89,6 +92,7 @@ const executeFile = (args, port, dataConsumer) => {
89
92
log ( 'error' , e )
90
93
}
91
94
board . close ( )
95
+ return Promise . resolve ( )
92
96
} )
93
97
}
94
98
@@ -115,7 +119,7 @@ const getFile = (args, port, dataConsumer) => {
115
119
const board = new Board ( )
116
120
const [ boardFilename , diskFilename ] = args
117
121
const consumer = dataConsumer || function ( ) { }
118
- board . open ( port )
122
+ return board . open ( port )
119
123
. then ( async ( ) => {
120
124
try {
121
125
let output = await board . fs_cat ( boardFilename , consumer )
@@ -126,6 +130,7 @@ const getFile = (args, port, dataConsumer) => {
126
130
log ( 'error' , e )
127
131
}
128
132
board . close ( )
133
+ return Promise . resolve ( )
129
134
} )
130
135
}
131
136
@@ -134,7 +139,7 @@ const removeFile = (args, port) => {
134
139
const board = new Board ( )
135
140
const [ boardFilename ] = args
136
141
137
- board . open ( port )
142
+ return board . open ( port )
138
143
. then ( async ( ) => {
139
144
try {
140
145
const out = await board . fs_rm ( boardFilename )
@@ -143,6 +148,7 @@ const removeFile = (args, port) => {
143
148
log ( 'error' , e )
144
149
}
145
150
board . close ( )
151
+ return Promise . resolve ( )
146
152
} )
147
153
}
148
154
@@ -151,7 +157,7 @@ const removeFolder = (args, port) => {
151
157
const board = new Board ( )
152
158
const [ boardDirname ] = args
153
159
154
- board . open ( port )
160
+ return board . open ( port )
155
161
. then ( async ( ) => {
156
162
try {
157
163
const out = await board . fs_rmdir ( boardDirname )
@@ -160,6 +166,7 @@ const removeFolder = (args, port) => {
160
166
log ( 'error' , e )
161
167
}
162
168
board . close ( )
169
+ return Promise . resolve ( )
163
170
} )
164
171
}
165
172
0 commit comments