@@ -16,6 +16,8 @@ class DeviceManager {
1616 constructor ( watcher , device ) {
1717 this . watcher = watcher ;
1818 this . device = device ;
19+ this . project = this . watcher . project ;
20+ this . pymakr = this . project . pymakr ;
1921 this . log = watcher . log . createChild ( device . name ) ;
2022
2123 /** @type {FileInstruction[] } */
@@ -25,11 +27,11 @@ class DeviceManager {
2527 }
2628
2729 get outOfSync ( ) {
28- return this . device . state . devUploadedAt . get ( ) !== this . watcher . project . updatedAt . get ( ) ;
30+ return this . device . state . devUploadedAt . get ( ) !== this . project . updatedAt . get ( ) ;
2931 }
3032
3133 get shouldUploadOnDev ( ) {
32- const uploadWhen = this . watcher . project . config . dev ?. uploadOnDevStart || "outOfSync" ;
34+ const uploadWhen = this . project . config . dev ?. uploadOnDevStart || "outOfSync" ;
3335 return uploadWhen === "always" || ( uploadWhen === "outOfSync" && this . outOfSync ) ;
3436 }
3537
@@ -39,7 +41,7 @@ class DeviceManager {
3941 const answer = await this . device . pymakr . notifier . notifications . deviceIsOutOfSync ( this ) ;
4042
4143 if ( this . shouldUploadOnDev || answer === "upload" )
42- await this . device . pymakr . commands . uploadProject ( { device : this . device , project : this . watcher . project } ) ;
44+ await this . device . pymakr . commands . uploadProject ( { device : this . device , project : this . project } ) ;
4345 }
4446
4547 /**
@@ -82,9 +84,11 @@ class DeviceManager {
8284 this . fileInstructions . length = 0 ;
8385 for ( const instruction of instructions ) modulesToDelete . push ( await this . runInstruction ( instruction ) ) ;
8486 }
87+ console . log ( "copying" , __dirname + "/fakemachine.py" ) ;
88+ await this . pymakr . commands . upload ( { fsPath : __dirname + "/fakemachine.py" } , this . device , "fakemachine.py" ) ;
8589
8690 /** @type {'restartScript'|'softRestartDevice'|'hardRestartDevice' } */
87- const onUpdate = this . watcher . project . config ?. dev ?. onUpdate || "restartScript" ;
91+ const onUpdate = this . project . config ?. dev ?. onUpdate || "restartScript" ;
8892 await this [ onUpdate ] ( modulesToDelete ) ;
8993
9094 await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
@@ -146,7 +150,7 @@ class DeviceManager {
146150 if ( action === "delete" ) {
147151 await this . device . remove ( target ) ;
148152 } else {
149- await this . watcher . project . pymakr . commands . upload ( { fsPath : file } , this . device , target ) ;
153+ await this . pymakr . commands . upload ( { fsPath : file } , this . device , target ) ;
150154 }
151155 return target ;
152156 }
0 commit comments