@@ -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,31 +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- if ( ! fs . existsSync ( path . join ( process . cwd ( ) , '/protos/' ) ) ) {
19- fs . mkdirSync ( path . join ( process . cwd ( ) , '/protos/' ) ) ;
17+ if ( ! fs . existsSync ( path . join ( process . resourcesPath , '/protos/' ) ) ) {
18+ fs . mkdirSync ( path . join ( process . resourcesPath , '/protos/' ) ) ;
2019 }
2120 } catch ( err ) {
2221 console . error ( err )
2322 }
24-
23+
2524 try {
26- while ( fs . existsSync ( path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) ) ) {
25+ while ( fs . existsSync ( path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) ) ) {
2726 //if file name exists try incrementing by 1
2827 protoID += 1 ;
2928 }
3029 } catch ( err ) {
3130 console . error ( err )
3231 }
33- // 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
3433
3534 // write to saveProto file for interaction with the server
36- fs . writeFileSync ( path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) , protoBodyData , 'utf-8' ) ;
35+ fs . writeFileSync ( path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) , protoBodyData , 'utf-8' ) ;
3736
3837 // define the modular client for testing
3938 // declare path variable of imported proto file
40-
41-
42- const PROTO_PATH = path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) ;
39+
40+
41+ const PROTO_PATH = path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) ;
4342
4443 // create gRPC package options
4544 const protoOptionsObj = {
0 commit comments