MCPcopy Index your code
hub / github.com/deployd/deployd / deleteEmptySubdirs

Function deleteEmptySubdirs

lib/resources/internal-resources.js:322–338  ·  view source on GitHub ↗
(basepath, id)

Source from the content-addressed store, hash-verified

320}
321
322function deleteEmptySubdirs(basepath, id) {
323 // go through a list of potentially leftover directories
324 var idParts = id.split('/');
325 var paths = idParts.map(function(part, index) {
326 return idParts.slice(0, index + 1).join('/');
327 }).filter(function(part) {
328 return part.length > 0;
329 });
330 paths.reverse();
331
332 // loop through the list and check if they're empty, then delete them
333 paths.forEach(function(pathPart) {
334 if (shell.ls('-R', path.join(basepath, 'resources', pathPart)).length === 0) {
335 shell.rm('-rf', path.join(basepath, 'resources', pathPart)); // delete empty directory
336 }
337 });
338}

Callers 2

writeFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected