Skip to content

Commit 367d6df

Browse files
authored
Merge pull request #271 from open-source-labs/dev
Repaired access to local read/write in electron to allow build
2 parents 64088e3 + b63951c commit 367d6df

File tree

4 files changed

+16
-49
lines changed

4 files changed

+16
-49
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/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"package-linux": "electron-builder build --linux",
1616
"gh-publish-mac": "electron-builder build --x64 --mac -p always",
1717
"gh-publish": "electron-builder build -mwl -p always",
18-
"postinstall": "npm rebuild --runtime=electron --target=7.0.1"
18+
"postinstall": "npm rebuild grpc --runtime=electron --target=7.0.1"
1919
},
2020
"author": {
2121
"name": "Swell",

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

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

src/client/protoParser.js

Lines changed: 14 additions & 5 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,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

Comments
 (0)