HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/treeify/examples/fs_tree.js
#!/usr/bin/env node

(function(){

   try {
      var dive = require('dive');
   } catch (ex) {
      console.error('this example requires "dive", please run "npm install dive"');
      process.exit(1);
   }

   var treeify = require('../treeify'),
       path = require('path'),
       fs = require('fs'),
       rootDir = process.argv.length < 3 ? '.' : process.argv[2],
       tree = {};

   if ( ! fs.existsSync(rootDir)) {
      console.error('path "' + rootDir + '" does not exist - unable to proceed!');
      process.exit(1);
   }

   console.log(rootDir !== '.' ? path.relative(process.cwd(), rootDir) : '.');

   function scanComplete() {
      process.stdout.write('\r       \r');
      console.log(treeify.asTree(tree, true));
   }

   dive(rootDir, { all: true, directories: true }, function(err, thisPath) {
      var relativePath = path.relative(rootDir, thisPath),
          node = tree;

      if (relativePath.indexOf('..') !== 0) {
         relativePath.split(path.sep).forEach(function(part) {
            typeof node[part] !== 'object' && (node[part] = {});
            node = node[part];
         });
      }

   }, scanComplete);

   process.stdout.write('wait... ');

})();