Comments (4)
I my have a solution. I remember an application that I built a year ago where I read files from a directory outside the node servers root. I had no problems whatsoever to read new files without restarting node.js. I will do a couple of tests...
from node-directory-tree.
I did a little test by changing to a directory outside the server root. But that did not work, then I built a little function based on my own code and it works! The file list gets updated. Tested with Postman.
// test read file list!
app.get('/filelist' , function(req, res){
var fileList = [];
//List all files and build an array of it.
fs.realpath(repodir + '/', function(err, path) {
if (err) {
console.log(err);
return;
}
//console.log('Path is : ' + path);
});
fs.readdir(repodir + '/', function(err, files) {
if (err) return;
for( i in files ){
//console.log("test" + files[i]);
fileList.push({'name': files[i]});
}
// send
res.send(JSON.stringify(fileList));
});
});
Looks as if I have to build my own directory-tree traversal solution. I have no idea why one works and the other is not...
from node-directory-tree.
SOLVED!
My bad, my implementation of your modul was a bit wrong, I declared to many variables. So it would hold the the listing forever I guess.
var dirTree = require('directory-tree');
var repotree = dirTree.directoryTree(repodir); <--- this will hold the value forever...
Now I tested this:
res.json(dirTree.directoryTree(repodir));
And of course it worked.
from node-directory-tree.
I'm glad you figured it out! Cheers!
from node-directory-tree.
Related Issues (20)
- Add parsing such as dree HOT 3
- Async support
- DirectoryTree - Missing custom field support in typescript interface HOT 5
- Project is unusable in 3.1.0 HOT 8
- Would be nice to have an option for excluding folders HOT 2
- Windows 11, latest, gettting children [Array] HOT 2
- Symlink option not properly configured HOT 3
- Feature request - Add glob option as url
- Issue with setting custom field HOT 1
- "TypeError: PATH.basename is not a function" HOT 3
- unable to exclude a directory HOT 1
- node-directory-tree License Agreement HOT 4
- Cannot find name 'IObj' HOT 3
- Feature request - Get all Disk availbles in a file system ( C, D, etc)
- Any way to change default attributes? HOT 1
- Does not return Symlinks HOT 3
- Feature request: Add a reverse tree option
- Missing properties `type` and `extension` in v3.0.0 HOT 4
- dirTree attributes and Typescript HOT 1
- Sorting directories first HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-directory-tree.