@@ -4,7 +4,6 @@ const protoLoader = require('@grpc/proto-loader');
44const path = require ( 'path' ) ;
55const uuid = require ( 'uuid' ) ;
66
7-
87async function protoParserFunc ( protoBodyData ) {
98
109 // define storage for .proto parsed content
@@ -15,21 +14,31 @@ async function protoParserFunc(protoBodyData) {
1514 let protoID = Math . floor ( Math . random ( ) * 10000 ) ;
1615 //if file path for that ID already exists, increment the ID
1716 try {
18- while ( fs . existsSync ( 'src/client/components/composer/protos/' + protoID + '.proto' ) ) {
17+ if ( ! fs . existsSync ( path . join ( process . resourcesPath , '/protos/' ) ) ) {
18+ fs . mkdirSync ( path . join ( process . resourcesPath , '/protos/' ) ) ;
19+ }
20+ } catch ( err ) {
21+ console . error ( err )
22+ }
23+
24+ try {
25+ while ( fs . existsSync ( path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) ) ) {
1926 //if file name exists try incrementing by 1
2027 protoID += 1 ;
2128 }
2229 } catch ( err ) {
2330 console . error ( err )
2431 }
25- // const dirName = remote.app.getAppPath(); // remote.app.getAppPath() stopped working at some point so switched to process.cwd()
32+ // const dirName = remote.app.getAppPath(); // remote.app.getAppPath() stopped working at some point so switched to process.resourcesPath
2633
2734 // write to saveProto file for interaction with the server
28- fs . writeFileSync ( path . join ( process . cwd ( ) , 'src/client/components/composer /protos/' + protoID + '.proto' ) , protoBodyData , 'utf-8' ) ;
35+ fs . writeFileSync ( path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) , protoBodyData , 'utf-8' ) ;
2936
3037 // define the modular client for testing
3138 // declare path variable of imported proto file
32- const PROTO_PATH = path . join ( process . cwd ( ) , 'src/client/components/composer/protos/' + protoID + '.proto' ) ;
39+
40+
41+ const PROTO_PATH = path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) ;
3342
3443 // create gRPC package options
3544 const protoOptionsObj = {
0 commit comments