@@ -15,7 +15,15 @@ async function protoParserFunc(protoBodyData) {
1515 let protoID = Math . floor ( Math . random ( ) * 10000 ) ;
1616 //if file path for that ID already exists, increment the ID
1717 try {
18- while ( fs . existsSync ( 'src/client/components/composer/protos/' + protoID + '.proto' ) ) {
18+ if ( ! fs . existsSync ( path . join ( process . cwd ( ) , '/protos/' ) ) ) {
19+ fs . mkdirSync ( path . join ( process . cwd ( ) , '/protos/' ) ) ;
20+ }
21+ } catch ( err ) {
22+ console . error ( err )
23+ }
24+
25+ try {
26+ while ( fs . existsSync ( path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) ) ) {
1927 //if file name exists try incrementing by 1
2028 protoID += 1 ;
2129 }
@@ -25,11 +33,13 @@ async function protoParserFunc(protoBodyData) {
2533 // const dirName = remote.app.getAppPath(); // remote.app.getAppPath() stopped working at some point so switched to process.cwd()
2634
2735 // 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' ) ;
36+ fs . writeFileSync ( path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) , protoBodyData , 'utf-8' ) ;
2937
3038 // define the modular client for testing
3139 // declare path variable of imported proto file
32- const PROTO_PATH = path . join ( process . cwd ( ) , 'src/client/components/composer/protos/' + protoID + '.proto' ) ;
40+
41+
42+ const PROTO_PATH = path . join ( process . cwd ( ) , '/protos/' + protoID + '.proto' ) ;
3343
3444 // create gRPC package options
3545 const protoOptionsObj = {
0 commit comments