Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery
/
devops
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0361c765
authored
Oct 22, 2018
by
Amir Aharon
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
support subdirs
parent
2b7f3db1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
tools/PollingSimulator/app.js
tools/PollingSimulator/app.js
View file @
0361c765
...
@@ -56,7 +56,8 @@ app.get("/*", function(req,res){
...
@@ -56,7 +56,8 @@ app.get("/*", function(req,res){
});
});
function
getCurrentPollingResp
(
path
){
function
getCurrentPollingResp
(
path
){
const
jsonFile
=
jsonFilesMap
[
path
];
let
prefix
=
trimSuffix
(
path
);
const
jsonFile
=
jsonFilesMap
[
prefix
];
if
(
jsonFile
){
if
(
jsonFile
){
if
(
Array
.
isArray
(
jsonFile
)){
if
(
Array
.
isArray
(
jsonFile
)){
return
jsonFile
.
map
(
entity
=>
getCurrentEntity
(
entity
));
return
jsonFile
.
map
(
entity
=>
getCurrentEntity
(
entity
));
...
@@ -145,6 +146,13 @@ function handleReadFile(filePath,filePrefix){
...
@@ -145,6 +146,13 @@ function handleReadFile(filePath,filePrefix){
}
}
function
trimSuffix
(
fileName
){
let
fileSuffixOffset
=
fileName
.
lastIndexOf
(
'.'
);
let
fileStartSuffix
=
0
;
let
fileSuffix
=
fileSuffixOffset
!=
-
1
?
fileName
.
slice
(
fileStartSuffix
,
fileSuffixOffset
)
:
fileName
;
return
fileSuffix
;
}
function
getFilePrefix
(
fileName
){
function
getFilePrefix
(
fileName
){
let
filePrefixOffset
=
fileName
.
lastIndexOf
(
'.'
);
let
filePrefixOffset
=
fileName
.
lastIndexOf
(
'.'
);
let
fileStartPrefix
=
fileName
.
lastIndexOf
(
'/'
);
let
fileStartPrefix
=
fileName
.
lastIndexOf
(
'/'
);
...
@@ -157,7 +165,7 @@ function getFilePrefix(fileName){
...
@@ -157,7 +165,7 @@ function getFilePrefix(fileName){
return
filePrefix
;
return
filePrefix
;
}
}
function
handleReadDirectory
(
dirPath
){
function
handleReadDirectory
(
dirPath
,
dirPrefix
){
fs
.
readdir
(
dirPath
,
function
(
err
,
items
)
{
fs
.
readdir
(
dirPath
,
function
(
err
,
items
)
{
console
.
log
(
items
);
console
.
log
(
items
);
/**
/**
...
@@ -166,7 +174,16 @@ function handleReadDirectory(dirPath){
...
@@ -166,7 +174,16 @@ function handleReadDirectory(dirPath){
*/
*/
items
.
forEach
(
item
=>
{
items
.
forEach
(
item
=>
{
let
filePrefix
=
getFilePrefix
(
item
);
let
filePrefix
=
getFilePrefix
(
item
);
handleReadFile
(
dirPath
+
'/'
+
item
,
filePrefix
);
if
(
dirPrefix
)
filePrefix
=
dirPrefix
+
'/'
+
filePrefix
;
let
itemPath
=
dirPath
+
'/'
+
item
;
fs
.
stat
(
itemPath
,
(
err
,
stats
)
=>
{
if
(
err
)
throw
err
;
if
(
stats
.
isFile
())
handleReadFile
(
itemPath
,
filePrefix
);
else
handleReadDirectory
(
itemPath
,
filePrefix
);
});
});
});
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment