Skip to content

Commit 3f5801f

Browse files
committed
use platform agnostic paths everywhere
1 parent f2b2d9a commit 3f5801f

6 files changed

Lines changed: 19 additions & 47 deletions

File tree

packages/flowtest-cli/graph/Graph.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Graph {
127127
this.logger.add(LogLevel.INFO, '', { type: 'delayNode', data: { delay } });
128128
result = {
129129
status: 'Success',
130+
data: prevNodeOutputData,
130131
};
131132
}
132133

@@ -136,6 +137,7 @@ class Graph {
136137
this.auth = node.data.type ? aNode.evaluate() : undefined;
137138
result = {
138139
status: 'Success',
140+
data: prevNodeOutputData,
139141
};
140142
}
141143

@@ -170,6 +172,7 @@ class Graph {
170172
} else {
171173
result = {
172174
status: 'Success',
175+
data: prevNodeOutputData,
173176
};
174177
}
175178
}
@@ -194,6 +197,7 @@ class Graph {
194197
}
195198
result = {
196199
status: 'Success',
200+
data: prevNodeOutputData,
197201
};
198202
}
199203

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const { ipcRenderer, contextBridge } = require('electron');
22
const path = require('path');
3+
const { isMacOS } = require('./src/utils/filemanager/filesystem');
34

45
contextBridge.exposeInMainWorld('ipcRenderer', {
56
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
67
on: (channel, handler) => ipcRenderer.on(channel, (event, ...args) => handler(...args)),
78
join: (...args) => path.join(...args),
89
relative: (...args) => path.relative(...args),
910
dirname: (...args) => path.dirname(...args),
11+
isMacOs: isMacOS,
1012
});

packages/flowtest-electron/src/utils/filemanager/createdirectory.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
const fs = require('fs');
2-
const { isDirectory, concatRoute, pathExists } = require('./filesystem');
2+
const { isDirectory, pathExists } = require('./filesystem');
3+
const path = require('path');
34

4-
const createDirectory = (name, path) => {
5+
const createDirectory = (name, basePath) => {
56
// now validate the name and path
67
if (!name) {
78
throw new Error('Directory name is required');
89
}
910

10-
if (!path) {
11+
if (!basePath) {
1112
throw new Error('Directory path is required');
1213
}
1314

1415
// check if the directory exists
15-
if (!isDirectory(path)) {
16+
if (!isDirectory(basePath)) {
1617
throw new Error('Path is not a directory');
1718
}
1819

1920
// check if the directory already exists
20-
const directoryPath = concatRoute(path, name);
21+
const directoryPath = path.join(basePath, name);
2122

2223
if (isDirectory(directoryPath)) {
2324
throw new Error('The directory already exists');

packages/flowtest-electron/src/utils/filemanager/filesystem.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@ const pathExists = (path) => {
2525
}
2626
};
2727

28-
function trim(text) {
29-
return String(text).replace(/^\/|\/$/g, '');
30-
}
31-
32-
/**
33-
* Concatenate the given paths to one single path
34-
*
35-
* @param {...string} segments
36-
* @returns {string}
37-
*/
38-
const concatRoute = (...segments) => {
39-
let path = segments
40-
.filter((value) => value && String(value).length > 0)
41-
.map((segment) => '/' + trim(segment))
42-
.join('');
43-
44-
return '/' + trim(path.replace(/(\/)+/g, '/'));
45-
};
46-
4728
const getSubdirectoriesFromRoot = (rootPath, pathname) => {
4829
// convert to unix style path
4930
pathname = slash(pathname);
@@ -68,6 +49,8 @@ const isMacOS = () => {
6849
return process.platform === 'darwin';
6950
};
7051

52+
const PATH_SEPARATOR = isWindowsOS() ? '\\' : '/';
53+
7154
const slash = (path) => {
7255
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
7356

@@ -78,13 +61,11 @@ const slash = (path) => {
7861
return path.replace(/\\/g, '/');
7962
};
8063

81-
const PATH_SEPARATOR = isWindowsOS() ? '\\' : '/';
82-
8364
module.exports = {
8465
isDirectory,
8566
pathExists,
86-
concatRoute,
8767
getSubdirectoriesFromRoot,
8868
getDirectoryName,
69+
isMacOS,
8970
PATH_SEPARATOR,
9071
};

src/components/molecules/flow/graph/Graph.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class Graph {
112112
this.logger.add(LogLevel.INFO, '', { type: 'delayNode', data: delay });
113113
result = {
114114
status: 'Success',
115+
data: prevNodeOutputData,
115116
};
116117
}
117118

@@ -120,6 +121,7 @@ class Graph {
120121
this.auth = node.data.type ? aNode.evaluate() : undefined;
121122
result = {
122123
status: 'Success',
124+
data: prevNodeOutputData,
123125
};
124126
}
125127

@@ -151,6 +153,7 @@ class Graph {
151153
} else {
152154
result = {
153155
status: 'Success',
156+
data: prevNodeOutputData,
154157
};
155158
}
156159
}
@@ -173,6 +176,7 @@ class Graph {
173176
}
174177
result = {
175178
status: 'Success',
179+
data: prevNodeOutputData,
176180
};
177181
}
178182

src/utils/filesystem.js

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

0 commit comments

Comments
 (0)