ubuntu resolute
This commit is contained in:
26
nodejs/commande/getRepos.js
Normal file
26
nodejs/commande/getRepos.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const fs = require('fs');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
module.exports = function(app, checkApiKey) {
|
||||
app.get('/action/getrepos', checkApiKey, (req, res) => {
|
||||
const repoPath = '/var/svn'; // Updated correct path
|
||||
|
||||
try {
|
||||
// Read the repositories directory
|
||||
const repos = fs.readdirSync(repoPath)
|
||||
.filter(item => fs.statSync(`${repoPath}/${item}`).isDirectory())
|
||||
.filter(item => fs.existsSync(`${repoPath}/${item}/format`)); // Verify it's a SVN repo
|
||||
|
||||
res.json({
|
||||
repositories: repos,
|
||||
count: repos.length
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
error: "Error reading repositories",
|
||||
details: error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user