@@ -77,17 +77,17 @@ export class EmulatorConnector extends Uploader {
7777 this . port = options . port ;
7878 }
7979
80- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8180 upload ( compiled : CompileOutput , listener ?: ( chunk : any ) => void ) : Promise < SubProcess > {
8281 return this . connectSocket ( compiled . file , listener ) ;
8382 }
8483
85- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8684 private connectSocket ( program : string , listener ?: ( chunk : any ) => void ) : Promise < SubProcess > {
87- return new Promise ( ( resolve , _reject ) => {
85+ const that = this ;
86+
87+ return new Promise ( function ( resolve , _reject ) {
8888 const client = new net . Socket ( ) ;
89- client . connect ( this . port , ( ) => {
90- this . emit ( UploaderEvents . connected ) ;
89+ client . connect ( that . port , ( ) => {
90+ that . emit ( UploaderEvents . connected ) ;
9191 if ( listener !== undefined ) {
9292 client . on ( 'data' , listener ) ;
9393 }
@@ -109,7 +109,6 @@ export class EmulatorUploader extends Uploader {
109109 this . args = args ;
110110 }
111111
112- // eslint-disable-next-line @typescript-eslint/no-explicit-any
113112 upload ( compiled : CompileOutput , listener ?: ( chunk : any ) => void ) : Promise < SubProcess > {
114113 return this . connectSocket ( compiled . file , listener ) ;
115114 }
@@ -119,16 +118,16 @@ export class EmulatorUploader extends Uploader {
119118 return spawn ( this . interpreter , _args ) ;
120119 }
121120
122- // eslint-disable-next-line @typescript-eslint/no-explicit-any
123121 private connectSocket ( program : string , listener ?: ( chunk : any ) => void ) : Promise < SubProcess > {
122+ const that = this ;
124123 const process = this . startWARDuino ( program ) ;
125124
126- return new Promise ( ( resolve , reject ) => {
125+ return new Promise ( function ( resolve , reject ) {
127126 if ( process === undefined ) {
128127 reject ( 'Failed to start process.' ) ;
129128 }
130129
131- this . emit ( UploaderEvents . started ) ;
130+ that . emit ( UploaderEvents . started ) ;
132131
133132 while ( process . stdout === undefined ) {
134133 // wait for stdout to become available
@@ -145,12 +144,12 @@ export class EmulatorUploader extends Uploader {
145144 listener ( data ) ;
146145 }
147146
148- this . emit ( UploaderEvents . connecting ) ;
147+ that . emit ( UploaderEvents . connecting ) ;
149148
150149 if ( data . includes ( 'Listening' ) ) {
151150 const client = new net . Socket ( ) ;
152- client . connect ( this . port , ( ) => {
153- this . emit ( UploaderEvents . connected ) ;
151+ client . connect ( that . port , ( ) => {
152+ that . emit ( UploaderEvents . connected ) ;
154153 if ( listener !== undefined ) {
155154 client . on ( 'data' , listener ) ;
156155 }
@@ -166,11 +165,11 @@ export class EmulatorUploader extends Uploader {
166165 } ) ;
167166
168167 reader . on ( 'close' , ( ) => {
169- this . emit ( UploaderEvents . failed ) ;
168+ that . emit ( UploaderEvents . failed ) ;
170169 reject ( `Could not connect. Error: ${ error } ` ) ;
171170 } ) ;
172171 } else {
173- this . emit ( UploaderEvents . failed ) ;
172+ that . emit ( UploaderEvents . failed ) ;
174173 reject ( ) ;
175174 }
176175 } ) ;
@@ -180,7 +179,6 @@ export class EmulatorUploader extends Uploader {
180179export class ArduinoUploader extends Uploader {
181180 private readonly sdkpath : string ;
182181 private readonly fqbn : string ;
183- // eslint-disable-next-line @typescript-eslint/no-explicit-any
184182 private readonly options : SerialPortOpenOptions < any > ;
185183
186184 constructor ( sdkpath : string , _args : string [ ] = [ ] , options : SerialOptions ) {
@@ -207,12 +205,13 @@ export class ArduinoUploader extends Uploader {
207205 }
208206
209207 private stage ( program : string ) : Promise < void > {
208+ const that = this ;
210209 return new Promise < void > ( ( resolve , reject ) => {
211210 const compile = exec ( `make compile PAUSED=true BINARY=${ program } ` , { cwd : this . sdkpath } ) ;
212211
213212 compile . on ( 'close' , ( code ) => {
214213 if ( code !== 0 ) {
215- this . emit ( UploaderEvents . failed ) ;
214+ that . emit ( UploaderEvents . failed ) ;
216215 reject ( 'staging failed: unable to build Arduino program' ) ;
217216 return ;
218217 }
@@ -222,14 +221,15 @@ export class ArduinoUploader extends Uploader {
222221 }
223222
224223 private flash ( ) : Promise < void > {
224+ const that = this ;
225225 return new Promise < void > ( ( resolve , reject ) => {
226226 const command = `make flash PORT=${ this . options . path } FQBN=${ this . fqbn } ` ;
227227
228228 const upload = exec ( command , { cwd : this . sdkpath } ) ;
229229
230230 upload . on ( 'close' , ( code ) => {
231231 if ( code !== 0 ) {
232- this . emit ( UploaderEvents . failed ) ;
232+ that . emit ( UploaderEvents . failed ) ;
233233 reject ( `unable to flash program to ${ this . fqbn } ` ) ;
234234 return ;
235235 }
@@ -239,17 +239,18 @@ export class ArduinoUploader extends Uploader {
239239 }
240240
241241 private connect ( ) : Promise < Serial > {
242+ const that = this ;
242243 return new Promise < Serial > ( ( resolve , reject ) => {
243244 const channel = new SerialPort ( this . options ,
244245 ( error ) => {
245246 if ( error ) {
246- this . emit ( UploaderEvents . failed ) ;
247+ that . emit ( UploaderEvents . failed ) ;
247248 reject ( `could not connect to serial port: ${ this . options . path } ` ) ;
248249 return ;
249250 }
250251 }
251252 ) ;
252- this . emit ( UploaderEvents . connected ) ;
253+ that . emit ( UploaderEvents . connected ) ;
253254 resolve ( new Serial ( channel ) ) ;
254255 } ) ;
255256 }
0 commit comments