Skip to content

Commit 67f2154

Browse files
authored
Merge pull request #68 from oslabs-beta/fixwriteaccess
Fixwriteaccess - replaced process.cwd() with process.resourcesPath in protoParser to make writing files successful in production mode current build confirmed to work on mac and windows machines
2 parents d01215a + 7be777e commit 67f2154

File tree

3 files changed

+10
-53
lines changed

3 files changed

+10
-53
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,4 @@ ehthumbs.db
5858

5959
# proto files #
6060
#####################
61-
src/client/components/composer/protos
62-
*.proto
61+
protos/

src/client/components/composer/protos/saveProto.proto

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/client/protoParser.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const protoLoader = require('@grpc/proto-loader');
44
const path = require('path');
55
const uuid = require('uuid');
66

7-
87
async 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

Comments
 (0)