@@ -4,7 +4,6 @@ const protoLoader = require('@grpc/proto-loader');
4
4
const path = require ( 'path' ) ;
5
5
const uuid = require ( 'uuid' ) ;
6
6
7
-
8
7
async function protoParserFunc ( protoBodyData ) {
9
8
10
9
// define storage for .proto parsed content
@@ -15,31 +14,31 @@ async function protoParserFunc(protoBodyData) {
15
14
let protoID = Math . floor ( Math . random ( ) * 10000 ) ;
16
15
//if file path for that ID already exists, increment the ID
17
16
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/' ) ) ;
20
19
}
21
20
} catch ( err ) {
22
21
console . error ( err )
23
22
}
24
-
23
+
25
24
try {
26
- while ( fs . existsSync ( path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) ) ) {
25
+ while ( fs . existsSync ( path . join ( process . resourcesPath , '/protos/' + protoID + '.proto' ) ) ) {
27
26
//if file name exists try incrementing by 1
28
27
protoID += 1 ;
29
28
}
30
29
} catch ( err ) {
31
30
console . error ( err )
32
31
}
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
34
33
35
34
// 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' ) ;
37
36
38
37
// define the modular client for testing
39
38
// 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' ) ;
43
42
44
43
// create gRPC package options
45
44
const protoOptionsObj = {
0 commit comments