@@ -54,8 +54,8 @@ const listFiles = (args, port) => {
54
54
. then ( async ( ) => {
55
55
const folder = args [ 0 ] || '/'
56
56
try {
57
- let output = await board . fs_ls ( folder )
58
- let files = extractFileArray ( output )
57
+ const output = await board . fs_ls ( folder )
58
+ const files = extractFileArray ( output )
59
59
console . log ( `files at "${ folder } "` , files )
60
60
} catch ( e ) {
61
61
console . log ( 'error' , e )
@@ -71,11 +71,11 @@ const executeString = (args, port) => {
71
71
board . open ( port )
72
72
. then ( ( ) => board . enter_raw_repl ( ) )
73
73
. then ( ( ) => board . exec_raw ( { command : code } ) )
74
- . then ( ( out ) => {
74
+ . then ( async ( out ) => {
75
+ await board . exit_raw_repl ( )
76
+ await board . close ( )
75
77
console . log ( out )
76
- return board . exit_raw_repl ( )
77
78
} )
78
- . then ( ( ) => board . close ( ) )
79
79
. catch ( ( err ) => {
80
80
console . log ( 'error' )
81
81
console . log ( err )
@@ -86,12 +86,13 @@ const executeString = (args, port) => {
86
86
87
87
const executeFile = ( args , port ) => {
88
88
ensurePort ( port )
89
- let board = new Board ( )
89
+ const board = new Board ( )
90
90
const filename = args [ 0 ] || ''
91
91
board . open ( port )
92
92
. then ( async ( ) => {
93
93
10000
try {
94
- await board . execfile ( filename )
94
+ const out = await board . execfile ( filename )
95
+ console . log ( out )
95
96
} catch ( e ) {
96
97
console . log ( 'error' , e )
97
98
}
@@ -106,7 +107,8 @@ const putFile = (args, port) => {
106
107
board . open ( port )
107
108
. then ( async ( ) => {
108
109
try {
109
- await board . fs_put ( diskFilename , boardFilename )
110
+ const out = await board . fs_put ( diskFilename , boardFilename )
111
+ console . log ( out )
110
112
} catch ( e ) {
111
113
console . log ( 'error' , e )
112
114
}
@@ -130,7 +132,40 @@ const getFile = (args, port) => {
130
132
}
131
133
board . close ( )
132
134
} )
135
+ }
136
+
137
+ const removeFile = ( args , port ) => {
138
+ ensurePort ( port )
139
+ const board = new Board ( )
140
+ const [ boardFilename ] = args
141
+
142
+ board . open ( port )
143
+ . then ( async ( ) => {
144
+ try {
145
+ const out = await board . fs_rm ( boardFilename )
146
+ console . log ( out )
147
+ } catch ( e ) {
148
+ console . log ( 'error' , e )
149
+ }
150
+ board . close ( )
151
+ } )
152
+ }
133
153
154
+ const removeFolder = ( args , port ) => {
155
+ ensurePort ( port )
156
+ const board = new Board ( )
157
+ const [ boardDirname ] = args
158
+
159
+ board . open ( port )
160
+ . then ( async ( ) => {
161
+ try {
162
+ const out = await board . fs_rmdir ( boardDirname )
163
+ console . log ( out )
164
+ } catch ( e ) {
165
+ console . log ( 'error' , e )
166
+ }
167
+ board . close ( )
168
+ } )
134
169
}
135
170
136
171
const operations = {
@@ -139,7 +174,9 @@ const operations = {
139
174
'--executestring' : executeString ,
140
175
'--executefile' : executeFile ,
141
176
'--putfile' : putFile ,
142
- '--getfile' : getFile
177
+ '--getfile' : getFile ,
178
+ '--removefile' : removeFile ,
179
+ '--removefolder' : removeFolder
143
180
}
144
181
145
182
let args = extractArguments ( process . argv )
0 commit comments