Socket
Socket
Sign inDemoInstall

dree

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dree - npm Package Compare versions

Comparing version 4.7.0 to 4.8.0

2

bundled/bin/index.js
#!/usr/bin/env node
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("../lib/index")):"function"==typeof define&&define.amd?define("dree",["../lib/index"],t):"object"==typeof exports?exports.dree=t(require("../lib/index")):e.dree=t(e.dree)}(this,(e=>(()=>{"use strict";var t={381:function(e,t,o){var n=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0});var i=o(314),r=o(896),s=o(699),d=o(699);function a(e){var t=/^\/(?<pattern>.*)\/(?<flags>[igm]*)?$/;return e?e.map((function(e){var o=e.match(t);return o?new RegExp(o.groups.pattern.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d"),o.groups.flags):e})):[]}function h(e){if(e)switch(e){case"ascending":return d.SortMethodPredefined.ALPHABETICAL;case"descending":return d.SortMethodPredefined.ALPHABETICAL_REVERSE;default:return e}}i.scriptName("dree").command("parse <source>","Save the directory tree as a text file",(function(e){e.positional("source",{describe:"The path of the root of the directory tree",type:"string"})}),(function(e){var t=e,o={symbolicLinks:t.symbolicLinks,followLinks:t.followLinks,showHidden:t.showHidden,depth:t.depth,exclude:a(t.exclude),extensions:t.extensions,sorted:h(t.sorted),homeShortcut:t.homeShortcut,skipErrors:t.skipErrors},n=t.source,i=t.dest,d=!t.dest||t.show,l=s.parse(n,o);d&&console.log(l),i&&(0,r.writeFileSync)(i,l)})).command("scan <source>","Save the directory tree as a json file",(function(e){e.positional("source",{describe:"The path of the root of the directory tree",type:"string"}).options({tabs:{describe:"How many tabs will be used to indent the resulted json",type:"number",default:0},pretty:{describe:"If the resulted json will be pretty printed with 4 tabs. Overwrites the tabs option",type:"boolean",default:!1}})}),(function(e){var t=e,o={stat:t.stat,normalize:t.normalize,symbolicLinks:t.symbolicLinks,followLinks:t.followLinks,sizeInBytes:t.sizeInBytes,size:t.size,hash:t.hash,hashAlgorithm:t.hashAlgorithm,hashEncoding:t.hashEncoding,showHidden:t.showHidden,depth:t.depth,exclude:a(t.exclude),matches:a(t.matches),emptyDirectory:t.emptyDirectory,excludeEmptyDirectories:t.excludeEmptyDirectories,descendants:t.descendants,descendantsIgnoreDirectories:t.descendantsIgnoreDirectories,extensions:t.extensions,sorted:h(t.sorted),homeShortcut:t.homeShortcut,skipErrors:t.skipErrors},n=t.source,i=t.dest,d=!t.dest||t.show,l=t.pretty?4:t.tabs,c=JSON.stringify(s.scan(n,o),null,l);d&&console.log(c),i&&(0,r.writeFileSync)(i,c)})).options({dest:{alias:"d",describe:"The path of the output file destination. If not specified, in any case the result will be printed on the command line.",type:"string"},show:{alias:"s",default:!1,describe:"Whether you want to print the result on the command line. This will be ignored and set to true if no destination is specified.",type:"boolean"},stat:{default:!1,describe:"Whether you want the fs.stat included in the json result",type:"boolean",hidden:!0},normalize:{default:!1,describe:"Whether you want to normalize the path in the json result",type:"boolean",hidden:!0},"symbolic-links":{default:!0,describe:"Whether you want to consider symbolic links during the elaboration, could not work on windows",type:"boolean",hidden:!0},"follow-links":{default:!1,describe:"Whether you want to follow symbolic links during the elaboration, could not work on windows",type:"boolean",hidden:!0},"size-in-bytes":{default:!0,describe:"Whether you want to include the size in bytes in the json result",type:"boolean",hidden:!0},size:{default:!0,describe:"Whether you want to include the size in a proper unit in the json result",type:"boolean",hidden:!0},hash:{default:!0,describe:"Whether you want to include the hash in the json result",type:"boolean",hidden:!0},"hash-algorithm":{default:"md5",describe:"The hash algorithm that you want to use for the hash in the json result",type:"string",choices:["md5","sha1"],hidden:!0},"hash-encoding":{default:"hex",describe:"The hash encoding that you want to use for the hash in the json result",type:"string",choiches:["hex","base64","latin1"],hidden:!0},"show-hidden":{default:!0,describe:"Whether you want to consider hidden files during the elaboration",type:"boolean",hidden:!0},depth:{default:void 0,describe:"The max depth wich could be reached during the elaboration from the given folder",type:"number",hidden:!0},exclude:{describe:"An array of strings (glob patterns) or regex (just write them as you would with js, e.g. /^[a-b]*$/g) whose all matched path will not be considered during the elaboration",type:"array",hidden:!0},matches:{describe:"An array of strings (glob patterns) or regex (just write them as you would with js, e.g. /^[a-b]*$/g) and all the non-matching paths will not be considered by the algorithm. Note: All the ancestors of a matching node will be added",type:"array",hidden:!0},extensions:{describe:"An array of strings containing all the extensions wich will be considered",type:"array",hidden:!0},"empty-directory":{default:!1,describe:"Whether you want to include the property isEmpty in the result",type:"boolean",hidden:!0},"exclude-empty-directories":{default:!1,describe:"Whether you want to exclude all the empty directories from the result, even if they contains nodes excluded by other options",type:"boolean",hidden:!0},sorted:{default:void 0,describe:"Whether you want the result to contain values sorted with a dree pre-defined sorting method. 'ascending' or 'descending' are kept for retrocompatibility. If not specified, the result values are not ordered.",type:"string",choices:n(n([],Object.values(d.SortMethodPredefined),!0),["ascending","descending"],!1),hidden:!0},descendants:{default:!1,describe:"Whether you want the result to contain the number of descendants for each node",type:"boolean",hidden:!0},"descendants-ignore-directories":{default:!1,describe:"Whether you want the result directories to be ignored when calculating the number of descendants",type:"boolean",hidden:!0},"home-shortcut":{default:!1,describe:"Whether you want the unix homedir shortcut ~ to be expanded to the user home directory",type:"boolean",hidden:!0},"skip-errors":{default:!0,describe:"Whether you want to skip folders and files wich give errors during the execution",type:"boolean",hidden:!0},options:{alias:"o",describe:"A path to a json config file. If an option is both on the file and in the command, the command one will be considered",config:!0}}).showHidden("all-options").completion("completion","Creates the completion bash script to add o your .bashrc in order to have the tab autocompletion for this cli service").demandCommand(1,"You must specify a command").strict().epilogue("For more information, find our manual at https://github.com/euberdeveloper/dree#readme").argv},314:e=>{e.exports=require("yargs")},896:e=>{e.exports=require("fs")},699:t=>{t.exports=e}},o={};return function e(n){var i=o[n];if(void 0!==i)return i.exports;var r=o[n]={exports:{}};return t[n].call(r.exports,r,r.exports,e),r.exports}(381)})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("../lib/index")):"function"==typeof define&&define.amd?define("dree",["../lib/index"],t):"object"==typeof exports?exports.dree=t(require("../lib/index")):e.dree=t(e.dree)}(this,(e=>(()=>{"use strict";var t={381:function(e,t,o){var n=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var n,r=0,i=t.length;r<i;r++)!n&&r in t||(n||(n=Array.prototype.slice.call(t,0,r)),n[r]=t[r]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0});var r=o(314),i=o(896),s=o(699),d=o(699);function a(e){var t=/^\/(?<pattern>.*)\/(?<flags>[igm]*)?$/;return e?e.map((function(e){var o=e.match(t);return o?new RegExp(o.groups.pattern.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d"),o.groups.flags):e})):[]}function h(e){if(e)switch(e){case"ascending":return d.SortMethodPredefined.ALPHABETICAL;case"descending":return d.SortMethodPredefined.ALPHABETICAL_REVERSE;default:return e}}function c(e){if(e)switch(e){case"ascending":return d.PostSortMethodPredefined.ALPHABETICAL;case"descending":return d.PostSortMethodPredefined.ALPHABETICAL_REVERSE;default:return e}}r.scriptName("dree").command("parse <source>","Save the directory tree as a text file",(function(e){e.positional("source",{describe:"The path of the root of the directory tree",type:"string"})}),(function(e){var t=e,o={symbolicLinks:t.symbolicLinks,followLinks:t.followLinks,showHidden:t.showHidden,depth:t.depth,exclude:a(t.exclude),extensions:t.extensions,sorted:h(t.sorted),homeShortcut:t.homeShortcut,skipErrors:t.skipErrors},n=t.source,r=t.dest,d=!t.dest||t.show,c=s.parse(n,o);d&&console.log(c),r&&(0,i.writeFileSync)(r,c)})).command("scan <source>","Save the directory tree as a json file",(function(e){e.positional("source",{describe:"The path of the root of the directory tree",type:"string"}).options({tabs:{describe:"How many tabs will be used to indent the resulted json",type:"number",default:0},pretty:{describe:"If the resulted json will be pretty printed with 4 tabs. Overwrites the tabs option",type:"boolean",default:!1}})}),(function(e){var t=e,o={stat:t.stat,normalize:t.normalize,symbolicLinks:t.symbolicLinks,followLinks:t.followLinks,sizeInBytes:t.sizeInBytes,size:t.size,hash:t.hash,hashAlgorithm:t.hashAlgorithm,hashEncoding:t.hashEncoding,showHidden:t.showHidden,depth:t.depth,exclude:a(t.exclude),matches:a(t.matches),emptyDirectory:t.emptyDirectory,excludeEmptyDirectories:t.excludeEmptyDirectories,descendants:t.descendants,descendantsIgnoreDirectories:t.descendantsIgnoreDirectories,extensions:t.extensions,sorted:h(t.sorted),postSorted:c(t.postSorted),homeShortcut:t.homeShortcut,skipErrors:t.skipErrors},n=t.source,r=t.dest,d=!t.dest||t.show,l=t.pretty?4:t.tabs,u=JSON.stringify(s.scan(n,o),null,l);d&&console.log(u),r&&(0,i.writeFileSync)(r,u)})).options({dest:{alias:"d",describe:"The path of the output file destination. If not specified, in any case the result will be printed on the command line.",type:"string"},show:{alias:"s",default:!1,describe:"Whether you want to print the result on the command line. This will be ignored and set to true if no destination is specified.",type:"boolean"},stat:{default:!1,describe:"Whether you want the fs.stat included in the json result",type:"boolean",hidden:!0},normalize:{default:!1,describe:"Whether you want to normalize the path in the json result",type:"boolean",hidden:!0},"symbolic-links":{default:!0,describe:"Whether you want to consider symbolic links during the elaboration, could not work on windows",type:"boolean",hidden:!0},"follow-links":{default:!1,describe:"Whether you want to follow symbolic links during the elaboration, could not work on windows",type:"boolean",hidden:!0},"size-in-bytes":{default:!0,describe:"Whether you want to include the size in bytes in the json result",type:"boolean",hidden:!0},size:{default:!0,describe:"Whether you want to include the size in a proper unit in the json result",type:"boolean",hidden:!0},hash:{default:!0,describe:"Whether you want to include the hash in the json result",type:"boolean",hidden:!0},"hash-algorithm":{default:"md5",describe:"The hash algorithm that you want to use for the hash in the json result",type:"string",choices:["md5","sha1"],hidden:!0},"hash-encoding":{default:"hex",describe:"The hash encoding that you want to use for the hash in the json result",type:"string",choiches:["hex","base64","latin1"],hidden:!0},"show-hidden":{default:!0,describe:"Whether you want to consider hidden files during the elaboration",type:"boolean",hidden:!0},depth:{default:void 0,describe:"The max depth wich could be reached during the elaboration from the given folder",type:"number",hidden:!0},exclude:{describe:"An array of strings (glob patterns) or regex (just write them as you would with js, e.g. /^[a-b]*$/g) whose all matched path will not be considered during the elaboration",type:"array",hidden:!0},matches:{describe:"An array of strings (glob patterns) or regex (just write them as you would with js, e.g. /^[a-b]*$/g) and all the non-matching paths will not be considered by the algorithm. Note: All the ancestors of a matching node will be added",type:"array",hidden:!0},extensions:{describe:"An array of strings containing all the extensions wich will be considered",type:"array",hidden:!0},"empty-directory":{default:!1,describe:"Whether you want to include the property isEmpty in the result",type:"boolean",hidden:!0},"exclude-empty-directories":{default:!1,describe:"Whether you want to exclude all the empty directories from the result, even if they contains nodes excluded by other options",type:"boolean",hidden:!0},sorted:{default:void 0,describe:"Whether you want the result to contain values sorted with a dree pre-defined sorting method. 'ascending' or 'descending' are kept for retrocompatibility. The sort is done before the scanning for the scan command. If not specified, the result values are not ordered.",type:"string",choices:n(n([],Object.values(d.SortMethodPredefined),!0),["ascending","descending"],!1),hidden:!0},postSorted:{default:void 0,describe:"Whether you want the result to contain values sorted with a dree pre-defined sorting method. 'ascending' or 'descending' are kept for retrocompatibility. The sort is done after the scanning for the scan command. If not specified, the result values are not ordered.",type:"string",choices:n(n([],Object.values(d.PostSortMethodPredefined),!0),["ascending","descending"],!1),hidden:!0},descendants:{default:!1,describe:"Whether you want the result to contain the number of descendants for each node",type:"boolean",hidden:!0},"descendants-ignore-directories":{default:!1,describe:"Whether you want the result directories to be ignored when calculating the number of descendants",type:"boolean",hidden:!0},"home-shortcut":{default:!1,describe:"Whether you want the unix homedir shortcut ~ to be expanded to the user home directory",type:"boolean",hidden:!0},"skip-errors":{default:!0,describe:"Whether you want to skip folders and files wich give errors during the execution",type:"boolean",hidden:!0},options:{alias:"o",describe:"A path to a json config file. If an option is both on the file and in the command, the command one will be considered",config:!0}}).showHidden("all-options").completion("completion","Creates the completion bash script to add o your .bashrc in order to have the tab autocompletion for this cli service").demandCommand(1,"You must specify a command").strict().epilogue("For more information, find our manual at https://github.com/euberdeveloper/dree#readme").argv},314:e=>{e.exports=require("yargs")},896:e=>{e.exports=require("fs")},699:t=>{t.exports=e}},o={};return function e(n){var r=o[n];if(void 0!==r)return r.exports;var i=o[n]={exports:{}};return t[n].call(i.exports,i,i.exports,e),i.exports}(381)})()));

@@ -5,2 +5,20 @@ import { BinaryToTextEncoding } from 'crypto';

/**
* Enum whose values are used to determine how the nodes should be sorted. Differently from [[SortMethodPredefined]],
* it specifies the behavior of the sorting after all the children of a folder are scanned.
*/
export declare enum PostSortMethodPredefined {
/** Alphabetical order */
ALPHABETICAL = "alpha",
/** Alphabetical order, reversed */
ALPHABETICAL_REVERSE = "antialpha",
/** Alphabetical order, case insensitive */
ALPHABETICAL_INSENSITIVE = "alpha-insensitive",
/** Alphabetical order, reversed, case insensitive */
ALPHABETICAL_INSENSITIVE_REVERSE = "antialpha-insensitive",
/** Folders first, files after */
FOLDERS_FIRST = "folders-first",
/** Files first, folders after */
FILES_FIRST = "files-first"
}
/**
* Enum whose values are used to determine how the paths should be sorted

@@ -168,2 +186,7 @@ */

/**
* If true, the child nodes of a node will be ordered. The value can be both boolean for default alpha order, a
* custom sorting function or a predefined sorting method in [[PostSortMethodPredefined]].
*/
postSorted?: boolean | PostSortMethodPredefined | PostSortDiscriminator;
/**
* If true, the unix homedir shortcut ~ will be expanded to the user home directory

@@ -270,2 +293,7 @@ */

/**
* If true, the child nodes of a node will be ordered. The value can be both boolean for default alpha order, a
* custom sorting function or a predefined sorting method in [[PostSortMethodPredefined]].
*/
postSorted?: boolean | PostSortMethodPredefined | PostSortDiscriminator;
/**
* If true, the unix homedir shortcut ~ will be expanded to the user home directory

@@ -293,2 +321,6 @@ */

/**
* Function used to sort nodes
*/
export type PostSortDiscriminator = (x: Dree, y: Dree) => number;
/**
* Function used to sort paths

@@ -295,0 +327,0 @@ */

@@ -1,1 +0,1 @@

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("dree",[],r):"object"==typeof exports?exports.dree=r():e.dree=r()}(this,(()=>(()=>{"use strict";var e={499:function(e,r,t){var n=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(s,i){function o(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var r;e.done?s(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,a)}c((n=n.apply(e,r||[])).next())}))},s=this&&this.__generator||function(e,r){var t,n,s,i,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(o=0)),o;)try{if(t=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=r.call(e,o)}catch(e){a=[6,e],n=0}finally{t=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(r,"__esModule",{value:!0}),r.parseTreeAsync=r.parseTree=r.parseAsync=r.parse=r.scanAsync=r.scan=r.SortMethodPredefined=r.Type=void 0;var i,o,a=t(928),c=t(857),u=t(982),l=t(756),h=t(896),f=t(943);!function(e){e.DIRECTORY="directory",e.FILE="file"}(i||(r.Type=i={})),function(e){e.ALPHABETICAL="alpha",e.ALPHABETICAL_REVERSE="antialpha",e.ALPHABETICAL_INSENSITIVE="alpha-insensitive",e.ALPHABETICAL_INSENSITIVE_REVERSE="antialpha-insensitive"}(o||(r.SortMethodPredefined=o={}));var d={stat:!1,normalize:!1,symbolicLinks:!0,followLinks:!1,sizeInBytes:!0,size:!0,hash:!0,hashAlgorithm:"md5",hashEncoding:"hex",showHidden:!0,depth:void 0,exclude:void 0,matches:void 0,extensions:void 0,emptyDirectory:!1,excludeEmptyDirectories:!1,descendants:!1,descendantsIgnoreDirectories:!1,sorted:!1,homeShortcut:!1,skipErrors:!0},p={symbolicLinks:!0,followLinks:!1,showHidden:!0,depth:void 0,exclude:void 0,extensions:void 0,sorted:!1,homeShortcut:!1,skipErrors:!0};function v(e,r){return(0,a.resolve)(r.homeShortcut?e.replace(/^~($|\/|\\)/,(0,c.homedir)()+"$1"):e)}function y(e){return(Array.isArray(e)?e:[e]).map((function(e){return e instanceof RegExp?e:(0,l.makeRe)(e,{dot:!0})})).filter((function(e){return e instanceof RegExp}))}function E(e){var r={};if(e){for(var t in d)r[t]=void 0!==e[t]?e[t]:d[t];r.depth<0&&(r.depth=0)}else r=d;return r}function m(e){var r={};if(e){for(var t in p)r[t]=void 0!==e[t]?e[t]:p[t];r.depth<0&&(r.depth=0)}else r=p;return r}function I(e){var r,t=["B","KB","MB","GB","TB"];for(r=0;r<t.length&&e>1e3;r++)e/=1e3;return Math.round(100*e)/100+" "+t[r]}function L(e,r){return e.localeCompare(r)}function b(e,r){return e.toLowerCase().localeCompare(r.toLowerCase())}function w(e,r){if(!r)return e;if(!0===r)return e.sort(L);if("string"==typeof r)switch(r){case o.ALPHABETICAL:return e.sort(L);case o.ALPHABETICAL_REVERSE:return e.sort(L).reverse();case o.ALPHABETICAL_INSENSITIVE:return e.sort(b);case o.ALPHABETICAL_INSENSITIVE_REVERSE:return e.sort(b).reverse();default:return e}else if("function"==typeof r)return e.sort(r)}function k(e,r){if(!r)return e;if(!0===r)return e.sort((function(e,r){return L(e.relativePath,r.relativePath)}));if("string"==typeof r)switch(r){case o.ALPHABETICAL:return e.sort((function(e,r){return L(e.relativePath,r.relativePath)}));case o.ALPHABETICAL_REVERSE:return e.sort((function(e,r){return L(e.relativePath,r.relativePath)})).reverse();case o.ALPHABETICAL_INSENSITIVE:return e.sort((function(e,r){return b(e.relativePath,r.relativePath)}));case o.ALPHABETICAL_INSENSITIVE_REVERSE:return e.sort((function(e,r){return b(e.relativePath,r.relativePath)})).reverse();default:return e}else if("function"==typeof r)return e.sort((function(e,t){return r(e.relativePath,t.relativePath)}))}function x(e,r,t,n,s,o){if(void 0!==n.depth&&t>n.depth)return null;var c=e===r?".":(0,a.relative)(e,r);if(n.exclude&&e!==r&&y(n.exclude).some((function(e){return e.test("/".concat(c))})))return null;var l,f,d=(0,a.basename)(r);try{l=(0,h.statSync)(r)}catch(e){if(n.skipErrors)return null;throw e}try{f=(0,h.lstatSync)(r)}catch(e){if(n.skipErrors)return null;throw e}var p,v=f.isSymbolicLink(),E=l.isFile()?i.FILE:i.DIRECTORY;if(!n.showHidden&&"."===d.charAt(0))return null;if(!n.symbolicLinks&&v)return null;if(n.hash){var m=n.hashAlgorithm;(p=(0,u.createHash)(m)).update(d)}var L={name:d,path:n.normalize?r.replace(/\\/g,"/"):r,relativePath:n.normalize?c.replace(/\\/g,"/"):c,type:E,isSymbolicLink:v,stat:n.followLinks?l:f};switch(n.stat||delete L.stat,E){case i.DIRECTORY:var b=[],k=void 0;if(n.followLinks||!v){try{k=w(k=(0,h.readdirSync)(r),n.sorted)}catch(e){if(n.skipErrors)return null;throw e}if(n.emptyDirectory&&(L.isEmpty=!k.length),k.forEach((function(i){var c=x(e,(0,a.resolve)(r,i),t+1,n,s,o);null!==c&&b.push(c)})),n.excludeEmptyDirectories&&!b.length)return null}if(n.matches&&e!==r){var A=y(n.matches);if(!b.length&&A.some((function(e){return!e.test("/".concat(c))})))return null}if(n.sizeInBytes||n.size){var g=b.reduce((function(e,r){return e+r.sizeInBytes}),0);L.sizeInBytes=g,L.size=n.size?I(g):void 0,n.sizeInBytes||b.forEach((function(e){return e.sizeInBytes=void 0}))}if(n.hash){b.forEach((function(e){p.update(e.hash)}));var R=n.hashEncoding;L.hash=p.digest(R)}n.descendants&&(L.descendants=b.reduce((function(e,r){var t;return e+(r.type===i.DIRECTORY&&n.descendantsIgnoreDirectories?0:1)+(null!==(t=r.descendants)&&void 0!==t?t:0)}),0)),b.length&&(L.children=b);break;case i.FILE:if(L.extension=(0,a.extname)(r).replace(".",""),n.extensions&&-1===n.extensions.indexOf(L.extension))return null;if(n.matches&&e!==r&&(A=y(n.matches)).some((function(e){return!e.test("/".concat(c))})))return null;if((n.sizeInBytes||n.size)&&(g=n.followLinks?l.size:f.size,L.sizeInBytes=g,L.size=n.size?I(g):void 0),n.hash){var S=void 0;try{S=(0,h.readFileSync)(r)}catch(e){if(n.skipErrors)return null;throw e}p.update(S),R=n.hashEncoding,L.hash=p.digest(R)}break;default:return null}return s&&E===i.FILE?s(L,n.followLinks?l:f):o&&E===i.DIRECTORY&&o(L,n.followLinks?l:f),L}function A(e,r,t,o,c,l){return n(this,void 0,void 0,(function(){var h,d,p,v,E,m,L,b,k,x,g,R,S,z,T,B,C,P,D,O=this;return s(this,(function(H){switch(H.label){case 0:if(void 0!==o.depth&&t>o.depth)return[2,null];if(h=e===r?".":(0,a.relative)(e,r),o.exclude&&e!==r&&y(o.exclude).some((function(e){return e.test("/".concat(h))})))return[2,null];d=(0,a.basename)(r),H.label=1;case 1:return H.trys.push([1,3,,4]),[4,(0,f.stat)(r)];case 2:return p=H.sent(),[3,4];case 3:if(v=H.sent(),o.skipErrors)return[2,null];throw v;case 4:return H.trys.push([4,6,,7]),[4,(0,f.lstat)(r)];case 5:return E=H.sent(),[3,7];case 6:if(m=H.sent(),o.skipErrors)return[2,null];throw m;case 7:if(L=E.isSymbolicLink(),b=p.isFile()?i.FILE:i.DIRECTORY,!o.showHidden&&"."===d.charAt(0))return[2,null];if(!o.symbolicLinks&&L)return[2,null];switch(o.hash&&(x=o.hashAlgorithm,(k=(0,u.createHash)(x)).update(d)),g={name:d,path:o.normalize?r.replace(/\\/g,"/"):r,relativePath:o.normalize?h.replace(/\\/g,"/"):h,type:b,isSymbolicLink:L,stat:o.followLinks?p:E},o.stat||delete g.stat,b){case i.DIRECTORY:return[3,8];case i.FILE:return[3,15]}return[3,21];case 8:if(R=[],S=void 0,!o.followLinks&&L)return[3,14];H.label=9;case 9:return H.trys.push([9,11,,12]),[4,(0,f.readdir)(r)];case 10:return S=w(S=H.sent(),o.sorted),[3,12];case 11:if(z=H.sent(),o.skipErrors)return[2,null];throw z;case 12:return o.emptyDirectory&&(g.isEmpty=!S.length),[4,Promise.all(S.map((function(i){return n(O,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,A(e,(0,a.resolve)(r,i),t+1,o,c,l)];case 1:return[2,n.sent()]}}))}))})))];case 13:if(R=(R=H.sent()).filter((function(e){return null!==e})),o.excludeEmptyDirectories&&!R.length)return[2,null];H.label=14;case 14:return o.matches&&e!==r&&(T=y(o.matches),!R.length&&T.some((function(e){return!e.test("/".concat(h))})))?[2,null]:((o.sizeInBytes||o.size)&&(B=R.reduce((function(e,r){return e+r.sizeInBytes}),0),g.sizeInBytes=B,g.size=o.size?I(B):void 0,o.sizeInBytes||R.forEach((function(e){return e.sizeInBytes=void 0}))),o.hash&&(R.forEach((function(e){k.update(e.hash)})),D=o.hashEncoding,g.hash=k.digest(D)),o.descendants&&(g.descendants=R.reduce((function(e,r){var t;return e+(r.type===i.DIRECTORY&&o.descendantsIgnoreDirectories?0:1)+(null!==(t=r.descendants)&&void 0!==t?t:0)}),0)),R.length&&(g.children=R),[3,22]);case 15:if(g.extension=(0,a.extname)(r).replace(".",""),o.extensions&&-1===o.extensions.indexOf(g.extension))return[2,null];if(o.matches&&e!==r&&(T=y(o.matches)).some((function(e){return!e.test("/".concat(h))})))return[2,null];if((o.sizeInBytes||o.size)&&(B=o.followLinks?p.size:E.size,g.sizeInBytes=B,g.size=o.size?I(B):void 0),!o.hash)return[3,20];C=void 0,H.label=16;case 16:return H.trys.push([16,18,,19]),[4,(0,f.readFile)(r)];case 17:return C=H.sent(),[3,19];case 18:if(P=H.sent(),o.skipErrors)return[2,null];throw P;case 19:k.update(C),D=o.hashEncoding,g.hash=k.digest(D),H.label=20;case 20:return[3,22];case 21:return[2,null];case 22:return c&&b===i.FILE?[4,c(g,o.followLinks?p:E)]:[3,24];case 23:return H.sent(),[3,26];case 24:return l&&b===i.DIRECTORY?[4,l(g,o.followLinks?p:E)]:[3,26];case 25:H.sent(),H.label=26;case 26:return[2,g]}}))}))}function g(e,r,t){return!r.symbolicLinks&&e.isSymbolicLink||!r.showHidden&&"."===e.name.charAt(0)||void 0!==r.extensions&&e.type===i.FILE&&-1===r.extensions.indexOf(e.extension)||r.exclude&&y(r.exclude).some((function(r){return r.test("/".concat(e.relativePath))}))||void 0!==r.depth&&t>r.depth}function R(e,r,t,n,s){var o="",c=r.map((function(o,c){var u="";if(void 0!==n.depth&&s>n.depth)return"";if(n.exclude&&y(n.exclude).some((function(r){return r.test("/".concat((0,a.relative)(e,o)))})))return"";var l,f,d=(0,a.basename)(o);try{l=(0,h.statSync)(o)}catch(e){if(n.skipErrors)return null;throw e}try{f=(0,h.lstatSync)(o)}catch(e){if(n.skipErrors)return null;throw e}var p=f.isSymbolicLink(),v=l.isFile()?i.FILE:i.DIRECTORY;if(!n.showHidden&&"."===d.charAt(0))return"";if(!n.symbolicLinks&&p)return"";var E=(0,a.extname)(o).replace(".","");if(n.extensions&&v===i.FILE&&-1===n.extensions.indexOf(E))return"";var m=p?">>":v===i.DIRECTORY?"─> ":"── ",I=t+(c===r.length-1?" ":"│ ");if(u+=m+d,(n.followLinks||!p)&&v===i.DIRECTORY){var L;try{L=w(L=(0,h.readdirSync)(o).map((function(e){return(0,a.resolve)(o,e)})),n.sorted)}catch(e){if(n.skipErrors)return null;throw e}u+=L.length?R(e,L,I,n,s+1):""}return u}));return c.filter((function(e){return!!e})).forEach((function(e,r,n){o+=t+(r===n.length-1?"└"+e:"├"+e)})),o}function S(e,r,t,o,c){return n(this,void 0,void 0,(function(){var u,l=this;return s(this,(function(h){switch(h.label){case 0:return u="",[4,Promise.all(r.map((function(u,h){return n(l,void 0,void 0,(function(){var n,l,d,p,v,E,m,I,L,b,k,x,A,g,R;return s(this,(function(s){switch(s.label){case 0:if(n="",void 0!==o.depth&&c>o.depth)return[2,""];if(o.exclude&&y(o.exclude).some((function(r){return r.test("/".concat((0,a.relative)(e,u)))})))return[2,""];l=(0,a.basename)(u),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,(0,f.stat)(u)];case 2:return d=s.sent(),[3,4];case 3:if(p=s.sent(),o.skipErrors)return[2,null];throw p;case 4:return s.trys.push([4,6,,7]),[4,(0,f.lstat)(u)];case 5:return v=s.sent(),[3,7];case 6:if(E=s.sent(),o.skipErrors)return[2,null];throw E;case 7:if(m=v.isSymbolicLink(),I=d.isFile()?i.FILE:i.DIRECTORY,!o.showHidden&&"."===l.charAt(0))return[2,""];if(!o.symbolicLinks&&m)return[2,""];if(L=(0,a.extname)(u).replace(".",""),o.extensions&&I===i.FILE&&-1===o.extensions.indexOf(L))return[2,""];if(b=m?">>":I===i.DIRECTORY?"─> ":"── ",k=t+(h===r.length-1?" ":"│ "),n+=b+l,!o.followLinks&&m||I!==i.DIRECTORY)return[3,15];s.label=8;case 8:return s.trys.push([8,10,,11]),[4,(0,f.readdir)(u)];case 9:return x=w(x=s.sent().map((function(e){return(0,a.resolve)(u,e)})),o.sorted),[3,11];case 10:if(A=s.sent(),o.skipErrors)return[2,null];throw A;case 11:return g=n,x.length?[4,S(e,x,k,o,c+1)]:[3,13];case 12:return R=s.sent(),[3,14];case 13:R="",s.label=14;case 14:n=g+R,s.label=15;case 15:return[2,n]}}))}))})))];case 1:return h.sent().filter((function(e){return!!e})).forEach((function(e,r,n){u+=t+(r===n.length-1?"└"+e:"├"+e)})),[2,u]}}))}))}function z(e,r,t,n){var s="";return(e=k(e,t.sorted)).filter((function(e){return!g(e,t,n)})).forEach((function(e,o,a){var c=e.isSymbolicLink?">>":e.type===i.DIRECTORY?"─> ":"── ",u=o===a.length-1?"└"+c:"├"+c,l=r+(o===a.length-1?" ":"│ ");s+=r+u+e.name,s+=!e.children||!t.followLinks&&e.isSymbolicLink?"":z(e.children,l,t,n+1)})),s}function T(e,r,t,o){return n(this,void 0,void 0,(function(){var n,a,c,u,l,h,f,d,p;return s(this,(function(s){switch(s.label){case 0:n="",e=k(e,t.sorted),a=e.filter((function(e){return!g(e,t,o)})),c=0,s.label=1;case 1:return c<a.length?(u=a[c],l=u.isSymbolicLink?">>":u.type===i.DIRECTORY?"─> ":"── ",h=c===a.length-1?"└"+l:"├"+l,f=r+(c===a.length-1?" ":"│ "),n+=r+h+u.name,d=n,!u.children||!t.followLinks&&u.isSymbolicLink?[3,3]:[4,T(u.children,f,t,o+1)]):[3,6];case 2:return p=s.sent(),[3,4];case 3:p="",s.label=4;case 4:n=d+p,s.label=5;case 5:return c++,[3,1];case 6:return[2,n]}}))}))}r.scan=function(e,r,t,n){var s=E(r),i=v(e,s),o=x(i,i,0,s,t,n);return o&&(o.sizeInBytes=s.sizeInBytes?o.sizeInBytes:void 0),o},r.scanAsync=function(e,r,t,i){return n(this,void 0,void 0,(function(){var n,o,a;return s(this,(function(s){switch(s.label){case 0:return n=E(r),[4,A(o=v(e,n),o,0,n,t,i)];case 1:return(a=s.sent())&&(a.sizeInBytes=n.sizeInBytes?a.sizeInBytes:void 0),[2,a]}}))}))},r.parse=function(e,r){var t,n,s="",i=m(r),o=v(e,i);s+=(0,a.basename)(o);try{t=(0,h.statSync)(o)}catch(e){if(i.skipErrors)return null;throw e}try{n=(0,h.lstatSync)(o)}catch(e){if(i.skipErrors)return null;throw e}var c=n.isSymbolicLink();if((i.followLinks||!c)&&t.isDirectory()){var u=void 0;try{u=w(u=(0,h.readdirSync)(o).map((function(e){return(0,a.resolve)(o,e)})),i.sorted)}catch(e){if(i.skipErrors)return null;throw e}s+=u.length?R(o,u,"\n ",i,1):""}return s},r.parseAsync=function(e,r){return n(this,void 0,void 0,(function(){var t,n,i,o,c,u,l,h,d,p,y,E,I;return s(this,(function(s){switch(s.label){case 0:t="",n=m(r),i=v(e,n),o=(0,a.basename)(i),t+=o,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,(0,f.stat)(i)];case 2:return c=s.sent(),[3,4];case 3:if(u=s.sent(),n.skipErrors)return[2,null];throw u;case 4:return s.trys.push([4,6,,7]),[4,(0,f.lstat)(i)];case 5:return l=s.sent(),[3,7];case 6:if(h=s.sent(),n.skipErrors)return[2,null];throw h;case 7:if(d=l.isSymbolicLink(),!n.followLinks&&d||!c.isDirectory())return[3,15];p=void 0,s.label=8;case 8:return s.trys.push([8,10,,11]),[4,(0,f.readdir)(i)];case 9:return p=w(p=s.sent().map((function(e){return(0,a.resolve)(i,e)})),n.sorted),[3,11];case 10:if(y=s.sent(),n.skipErrors)return[2,null];throw y;case 11:return E=t,p.length?[4,S(i,p,"\n ",n,1)]:[3,13];case 12:return I=s.sent(),[3,14];case 13:I="",s.label=14;case 14:t=E+I,s.label=15;case 15:return[2,t]}}))}))},r.parseTree=function(e,r){var t="",n=m(r);return(t+=e?e.name:"")+(e.children?z(e.children,"\n ",n,1):"")},r.parseTreeAsync=function(e,r){return n(this,void 0,void 0,(function(){var t,n,i,o;return s(this,(function(s){switch(s.label){case 0:return t="",n=m(r),t+=e?e.name:"",i=t,e.children?[4,T(e.children,"\n ",n,1)]:[3,2];case 1:return o=s.sent(),[3,3];case 2:o="",s.label=3;case 3:return[2,t=i+o]}}))}))}},756:e=>{e.exports=require("minimatch")},982:e=>{e.exports=require("crypto")},896:e=>{e.exports=require("fs")},943:e=>{e.exports=require("fs/promises")},857:e=>{e.exports=require("os")},928:e=>{e.exports=require("path")}},r={};return function t(n){var s=r[n];if(void 0!==s)return s.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(499)})()));
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("dree",[],r):"object"==typeof exports?exports.dree=r():e.dree=r()}(this,(()=>(()=>{"use strict";var e={499:function(e,r,t){var n=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(s,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var r;e.done?s(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(o,a)}u((n=n.apply(e,r||[])).next())}))},s=this&&this.__generator||function(e,r){var t,n,s,i,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(o=0)),o;)try{if(t=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=r.call(e,o)}catch(e){a=[6,e],n=0}finally{t=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(r,"__esModule",{value:!0}),r.parseTreeAsync=r.parseTree=r.parseAsync=r.parse=r.scanAsync=r.scan=r.PostSortMethodPredefined=r.SortMethodPredefined=r.Type=void 0;var i,o,a,u=t(928),c=t(857),l=t(982),f=t(756),h=t(896),d=t(943);!function(e){e.DIRECTORY="directory",e.FILE="file"}(i||(r.Type=i={})),function(e){e.ALPHABETICAL="alpha",e.ALPHABETICAL_REVERSE="antialpha",e.ALPHABETICAL_INSENSITIVE="alpha-insensitive",e.ALPHABETICAL_INSENSITIVE_REVERSE="antialpha-insensitive"}(o||(r.SortMethodPredefined=o={})),function(e){e.ALPHABETICAL="alpha",e.ALPHABETICAL_REVERSE="antialpha",e.ALPHABETICAL_INSENSITIVE="alpha-insensitive",e.ALPHABETICAL_INSENSITIVE_REVERSE="antialpha-insensitive",e.FOLDERS_FIRST="folders-first",e.FILES_FIRST="files-first"}(a||(r.PostSortMethodPredefined=a={}));var p={stat:!1,normalize:!1,symbolicLinks:!0,followLinks:!1,sizeInBytes:!0,size:!0,hash:!0,hashAlgorithm:"md5",hashEncoding:"hex",showHidden:!0,depth:void 0,exclude:void 0,matches:void 0,extensions:void 0,emptyDirectory:!1,excludeEmptyDirectories:!1,descendants:!1,descendantsIgnoreDirectories:!1,sorted:!1,postSorted:!1,homeShortcut:!1,skipErrors:!0},E={symbolicLinks:!0,followLinks:!1,showHidden:!0,depth:void 0,exclude:void 0,extensions:void 0,sorted:!1,postSorted:!1,homeShortcut:!1,skipErrors:!0};function v(e,r){return(0,u.resolve)(r.homeShortcut?e.replace(/^~($|\/|\\)/,(0,c.homedir)()+"$1"):e)}function y(e){return(Array.isArray(e)?e:[e]).map((function(e){return e instanceof RegExp?e:(0,f.makeRe)(e,{dot:!0})})).filter((function(e){return e instanceof RegExp}))}function I(e){var r={};if(e){for(var t in p)r[t]=void 0!==e[t]?e[t]:p[t];r.depth<0&&(r.depth=0)}else r=p;return r}function m(e){var r={};if(e){for(var t in E)r[t]=void 0!==e[t]?e[t]:E[t];r.depth<0&&(r.depth=0)}else r=E;return r}function L(e){var r,t=["B","KB","MB","GB","TB"];for(r=0;r<t.length&&e>1e3;r++)e/=1e3;return Math.round(100*e)/100+" "+t[r]}function A(e,r){return e.localeCompare(r)}function S(e,r){return e.toLowerCase().localeCompare(r.toLowerCase())}function b(e,r){if(!r)return e;if(!0===r)return e.sort(A);if("string"==typeof r)switch(r){case o.ALPHABETICAL:return e.sort(A);case o.ALPHABETICAL_REVERSE:return e.sort(A).reverse();case o.ALPHABETICAL_INSENSITIVE:return e.sort(S);case o.ALPHABETICAL_INSENSITIVE_REVERSE:return e.sort(S).reverse();default:return e}else if("function"==typeof r)return e.sort(r)}function w(e,r){return A(e.name,r.name)}function R(e,r){return S(e.name,r.name)}function k(e,r){return e.type===i.DIRECTORY&&r.type===i.FILE?-1:e.type===i.FILE&&r.type===i.DIRECTORY?1:0}function x(e,r){return e.type===i.FILE&&r.type===i.DIRECTORY?-1:e.type===i.DIRECTORY&&r.type===i.FILE?1:0}function T(e,r){if(!r)return e;if(!0===r)return e.sort(w);if("string"==typeof r)switch(r){case a.ALPHABETICAL:return e.sort(w);case a.ALPHABETICAL_REVERSE:return e.sort(w).reverse();case a.ALPHABETICAL_INSENSITIVE:return e.sort(R);case a.ALPHABETICAL_INSENSITIVE_REVERSE:return e.sort(R).reverse();case a.FOLDERS_FIRST:return e.sort(k);case a.FILES_FIRST:return e.sort(x);default:return e}else if("function"==typeof r)return e.sort(r)}function g(e,r){if(!r)return e;if(!0===r)return e.sort((function(e,r){return A(e.relativePath,r.relativePath)}));if("string"==typeof r)switch(r){case o.ALPHABETICAL:return e.sort((function(e,r){return A(e.relativePath,r.relativePath)}));case o.ALPHABETICAL_REVERSE:return e.sort((function(e,r){return A(e.relativePath,r.relativePath)})).reverse();case o.ALPHABETICAL_INSENSITIVE:return e.sort((function(e,r){return S(e.relativePath,r.relativePath)}));case o.ALPHABETICAL_INSENSITIVE_REVERSE:return e.sort((function(e,r){return S(e.relativePath,r.relativePath)})).reverse();default:return e}else if("function"==typeof r)return e.sort((function(e,t){return r(e.relativePath,t.relativePath)}))}function B(e,r,t,n,s,o){if(void 0!==n.depth&&t>n.depth)return null;var a=e===r?".":(0,u.relative)(e,r);if(n.exclude&&e!==r&&y(n.exclude).some((function(e){return e.test("/".concat(a))})))return null;var c,f,d=(0,u.basename)(r);try{c=(0,h.statSync)(r)}catch(e){if(n.skipErrors)return null;throw e}try{f=(0,h.lstatSync)(r)}catch(e){if(n.skipErrors)return null;throw e}var p,E=f.isSymbolicLink(),v=c.isFile()?i.FILE:i.DIRECTORY;if(!n.showHidden&&"."===d.charAt(0))return null;if(!n.symbolicLinks&&E)return null;if(n.hash){var I=n.hashAlgorithm;(p=(0,l.createHash)(I)).update(d)}var m={name:d,path:n.normalize?r.replace(/\\/g,"/"):r,relativePath:n.normalize?a.replace(/\\/g,"/"):a,type:v,isSymbolicLink:E,stat:n.followLinks?c:f};switch(n.stat||delete m.stat,v){case i.DIRECTORY:var A=[],S=void 0;if(n.followLinks||!E){try{S=b(S=(0,h.readdirSync)(r),n.sorted)}catch(e){if(n.skipErrors)return null;throw e}if(n.emptyDirectory&&(m.isEmpty=!S.length),S.forEach((function(i){var a=B(e,(0,u.resolve)(r,i),t+1,n,s,o);null!==a&&A.push(a)})),n.excludeEmptyDirectories&&!A.length)return null}if(n.matches&&e!==r){var w=y(n.matches);if(!A.length&&w.some((function(e){return!e.test("/".concat(a))})))return null}if(n.sizeInBytes||n.size){var R=A.reduce((function(e,r){return e+r.sizeInBytes}),0);m.sizeInBytes=R,m.size=n.size?L(R):void 0,n.sizeInBytes||A.forEach((function(e){return e.sizeInBytes=void 0}))}if(n.hash){A.forEach((function(e){p.update(e.hash)}));var k=n.hashEncoding;m.hash=p.digest(k)}n.descendants&&(m.descendants=A.reduce((function(e,r){var t;return e+(r.type===i.DIRECTORY&&n.descendantsIgnoreDirectories?0:1)+(null!==(t=r.descendants)&&void 0!==t?t:0)}),0)),A.length&&(m.children=n.postSorted?T(A,n.postSorted):A);break;case i.FILE:if(m.extension=(0,u.extname)(r).replace(".",""),n.extensions&&-1===n.extensions.indexOf(m.extension))return null;if(n.matches&&e!==r&&(w=y(n.matches)).some((function(e){return!e.test("/".concat(a))})))return null;if((n.sizeInBytes||n.size)&&(R=n.followLinks?c.size:f.size,m.sizeInBytes=R,m.size=n.size?L(R):void 0),n.hash){var x=void 0;try{x=(0,h.readFileSync)(r)}catch(e){if(n.skipErrors)return null;throw e}p.update(x),k=n.hashEncoding,m.hash=p.digest(k)}break;default:return null}return s&&v===i.FILE?s(m,n.followLinks?c:f):o&&v===i.DIRECTORY&&o(m,n.followLinks?c:f),m}function C(e,r,t,o,a,c){return n(this,void 0,void 0,(function(){var f,h,p,E,v,I,m,A,S,w,R,k,x,g,B,P,z,D,F,_=this;return s(this,(function(H){switch(H.label){case 0:if(void 0!==o.depth&&t>o.depth)return[2,null];if(f=e===r?".":(0,u.relative)(e,r),o.exclude&&e!==r&&y(o.exclude).some((function(e){return e.test("/".concat(f))})))return[2,null];h=(0,u.basename)(r),H.label=1;case 1:return H.trys.push([1,3,,4]),[4,(0,d.stat)(r)];case 2:return p=H.sent(),[3,4];case 3:if(E=H.sent(),o.skipErrors)return[2,null];throw E;case 4:return H.trys.push([4,6,,7]),[4,(0,d.lstat)(r)];case 5:return v=H.sent(),[3,7];case 6:if(I=H.sent(),o.skipErrors)return[2,null];throw I;case 7:if(m=v.isSymbolicLink(),A=p.isFile()?i.FILE:i.DIRECTORY,!o.showHidden&&"."===h.charAt(0))return[2,null];if(!o.symbolicLinks&&m)return[2,null];switch(o.hash&&(w=o.hashAlgorithm,(S=(0,l.createHash)(w)).update(h)),R={name:h,path:o.normalize?r.replace(/\\/g,"/"):r,relativePath:o.normalize?f.replace(/\\/g,"/"):f,type:A,isSymbolicLink:m,stat:o.followLinks?p:v},o.stat||delete R.stat,A){case i.DIRECTORY:return[3,8];case i.FILE:return[3,15]}return[3,21];case 8:if(k=[],x=void 0,!o.followLinks&&m)return[3,14];H.label=9;case 9:return H.trys.push([9,11,,12]),[4,(0,d.readdir)(r)];case 10:return x=b(x=H.sent(),o.sorted),[3,12];case 11:if(g=H.sent(),o.skipErrors)return[2,null];throw g;case 12:return o.emptyDirectory&&(R.isEmpty=!x.length),[4,Promise.all(x.map((function(i){return n(_,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,C(e,(0,u.resolve)(r,i),t+1,o,a,c)];case 1:return[2,n.sent()]}}))}))})))];case 13:if(k=(k=H.sent()).filter((function(e){return null!==e})),o.excludeEmptyDirectories&&!k.length)return[2,null];H.label=14;case 14:return o.matches&&e!==r&&(B=y(o.matches),!k.length&&B.some((function(e){return!e.test("/".concat(f))})))?[2,null]:((o.sizeInBytes||o.size)&&(P=k.reduce((function(e,r){return e+r.sizeInBytes}),0),R.sizeInBytes=P,R.size=o.size?L(P):void 0,o.sizeInBytes||k.forEach((function(e){return e.sizeInBytes=void 0}))),o.hash&&(k.forEach((function(e){S.update(e.hash)})),F=o.hashEncoding,R.hash=S.digest(F)),o.descendants&&(R.descendants=k.reduce((function(e,r){var t;return e+(r.type===i.DIRECTORY&&o.descendantsIgnoreDirectories?0:1)+(null!==(t=r.descendants)&&void 0!==t?t:0)}),0)),k.length&&(R.children=o.postSorted?T(k,o.postSorted):k),[3,22]);case 15:if(R.extension=(0,u.extname)(r).replace(".",""),o.extensions&&-1===o.extensions.indexOf(R.extension))return[2,null];if(o.matches&&e!==r&&(B=y(o.matches)).some((function(e){return!e.test("/".concat(f))})))return[2,null];if((o.sizeInBytes||o.size)&&(P=o.followLinks?p.size:v.size,R.sizeInBytes=P,R.size=o.size?L(P):void 0),!o.hash)return[3,20];z=void 0,H.label=16;case 16:return H.trys.push([16,18,,19]),[4,(0,d.readFile)(r)];case 17:return z=H.sent(),[3,19];case 18:if(D=H.sent(),o.skipErrors)return[2,null];throw D;case 19:S.update(z),F=o.hashEncoding,R.hash=S.digest(F),H.label=20;case 20:return[3,22];case 21:return[2,null];case 22:return a&&A===i.FILE?[4,a(R,o.followLinks?p:v)]:[3,24];case 23:return H.sent(),[3,26];case 24:return c&&A===i.DIRECTORY?[4,c(R,o.followLinks?p:v)]:[3,26];case 25:H.sent(),H.label=26;case 26:return[2,R]}}))}))}function P(e,r,t){return!r.symbolicLinks&&e.isSymbolicLink||!r.showHidden&&"."===e.name.charAt(0)||void 0!==r.extensions&&e.type===i.FILE&&-1===r.extensions.indexOf(e.extension)||r.exclude&&y(r.exclude).some((function(r){return r.test("/".concat(e.relativePath))}))||void 0!==r.depth&&t>r.depth}function z(e,r,t,n,s){var o="",a=r.map((function(o,a){var c="";if(void 0!==n.depth&&s>n.depth)return"";if(n.exclude&&y(n.exclude).some((function(r){return r.test("/".concat((0,u.relative)(e,o)))})))return"";var l,f,d=(0,u.basename)(o);try{l=(0,h.statSync)(o)}catch(e){if(n.skipErrors)return null;throw e}try{f=(0,h.lstatSync)(o)}catch(e){if(n.skipErrors)return null;throw e}var p=f.isSymbolicLink(),E=l.isFile()?i.FILE:i.DIRECTORY;if(!n.showHidden&&"."===d.charAt(0))return"";if(!n.symbolicLinks&&p)return"";var v=(0,u.extname)(o).replace(".","");if(n.extensions&&E===i.FILE&&-1===n.extensions.indexOf(v))return"";var I=p?">>":E===i.DIRECTORY?"─> ":"── ",m=t+(a===r.length-1?" ":"│ ");if(c+=I+d,(n.followLinks||!p)&&E===i.DIRECTORY){var L;try{L=b(L=(0,h.readdirSync)(o).map((function(e){return(0,u.resolve)(o,e)})),n.sorted)}catch(e){if(n.skipErrors)return null;throw e}c+=L.length?z(e,L,m,n,s+1):""}return c}));return a.filter((function(e){return!!e})).forEach((function(e,r,n){o+=t+(r===n.length-1?"└"+e:"├"+e)})),o}function D(e,r,t,o,a){return n(this,void 0,void 0,(function(){var c,l=this;return s(this,(function(f){switch(f.label){case 0:return c="",[4,Promise.all(r.map((function(c,f){return n(l,void 0,void 0,(function(){var n,l,h,p,E,v,I,m,L,A,S,w,R,k,x;return s(this,(function(s){switch(s.label){case 0:if(n="",void 0!==o.depth&&a>o.depth)return[2,""];if(o.exclude&&y(o.exclude).some((function(r){return r.test("/".concat((0,u.relative)(e,c)))})))return[2,""];l=(0,u.basename)(c),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,(0,d.stat)(c)];case 2:return h=s.sent(),[3,4];case 3:if(p=s.sent(),o.skipErrors)return[2,null];throw p;case 4:return s.trys.push([4,6,,7]),[4,(0,d.lstat)(c)];case 5:return E=s.sent(),[3,7];case 6:if(v=s.sent(),o.skipErrors)return[2,null];throw v;case 7:if(I=E.isSymbolicLink(),m=h.isFile()?i.FILE:i.DIRECTORY,!o.showHidden&&"."===l.charAt(0))return[2,""];if(!o.symbolicLinks&&I)return[2,""];if(L=(0,u.extname)(c).replace(".",""),o.extensions&&m===i.FILE&&-1===o.extensions.indexOf(L))return[2,""];if(A=I?">>":m===i.DIRECTORY?"─> ":"── ",S=t+(f===r.length-1?" ":"│ "),n+=A+l,!o.followLinks&&I||m!==i.DIRECTORY)return[3,15];s.label=8;case 8:return s.trys.push([8,10,,11]),[4,(0,d.readdir)(c)];case 9:return w=b(w=s.sent().map((function(e){return(0,u.resolve)(c,e)})),o.sorted),[3,11];case 10:if(R=s.sent(),o.skipErrors)return[2,null];throw R;case 11:return k=n,w.length?[4,D(e,w,S,o,a+1)]:[3,13];case 12:return x=s.sent(),[3,14];case 13:x="",s.label=14;case 14:n=k+x,s.label=15;case 15:return[2,n]}}))}))})))];case 1:return f.sent().filter((function(e){return!!e})).forEach((function(e,r,n){c+=t+(r===n.length-1?"└"+e:"├"+e)})),[2,c]}}))}))}function F(e,r,t,n){var s="";return(e=g(e,t.sorted)).filter((function(e){return!P(e,t,n)})).forEach((function(e,o,a){var u=e.isSymbolicLink?">>":e.type===i.DIRECTORY?"─> ":"── ",c=o===a.length-1?"└"+u:"├"+u,l=r+(o===a.length-1?" ":"│ ");s+=r+c+e.name,s+=!e.children||!t.followLinks&&e.isSymbolicLink?"":F(e.children,l,t,n+1)})),s}function _(e,r,t,o){return n(this,void 0,void 0,(function(){var n,a,u,c,l,f,h,d,p;return s(this,(function(s){switch(s.label){case 0:n="",e=g(e,t.sorted),a=e.filter((function(e){return!P(e,t,o)})),u=0,s.label=1;case 1:return u<a.length?(c=a[u],l=c.isSymbolicLink?">>":c.type===i.DIRECTORY?"─> ":"── ",f=u===a.length-1?"└"+l:"├"+l,h=r+(u===a.length-1?" ":"│ "),n+=r+f+c.name,d=n,!c.children||!t.followLinks&&c.isSymbolicLink?[3,3]:[4,_(c.children,h,t,o+1)]):[3,6];case 2:return p=s.sent(),[3,4];case 3:p="",s.label=4;case 4:n=d+p,s.label=5;case 5:return u++,[3,1];case 6:return[2,n]}}))}))}r.scan=function(e,r,t,n){var s=I(r),i=v(e,s),o=B(i,i,0,s,t,n);return o&&(o.sizeInBytes=s.sizeInBytes?o.sizeInBytes:void 0),o},r.scanAsync=function(e,r,t,i){return n(this,void 0,void 0,(function(){var n,o,a;return s(this,(function(s){switch(s.label){case 0:return n=I(r),[4,C(o=v(e,n),o,0,n,t,i)];case 1:return(a=s.sent())&&(a.sizeInBytes=n.sizeInBytes?a.sizeInBytes:void 0),[2,a]}}))}))},r.parse=function(e,r){var t,n,s="",i=m(r),o=v(e,i);s+=(0,u.basename)(o);try{t=(0,h.statSync)(o)}catch(e){if(i.skipErrors)return null;throw e}try{n=(0,h.lstatSync)(o)}catch(e){if(i.skipErrors)return null;throw e}var a=n.isSymbolicLink();if((i.followLinks||!a)&&t.isDirectory()){var c=void 0;try{c=b(c=(0,h.readdirSync)(o).map((function(e){return(0,u.resolve)(o,e)})),i.sorted)}catch(e){if(i.skipErrors)return null;throw e}s+=c.length?z(o,c,"\n ",i,1):""}return s},r.parseAsync=function(e,r){return n(this,void 0,void 0,(function(){var t,n,i,o,a,c,l,f,h,p,E,y,I;return s(this,(function(s){switch(s.label){case 0:t="",n=m(r),i=v(e,n),o=(0,u.basename)(i),t+=o,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,(0,d.stat)(i)];case 2:return a=s.sent(),[3,4];case 3:if(c=s.sent(),n.skipErrors)return[2,null];throw c;case 4:return s.trys.push([4,6,,7]),[4,(0,d.lstat)(i)];case 5:return l=s.sent(),[3,7];case 6:if(f=s.sent(),n.skipErrors)return[2,null];throw f;case 7:if(h=l.isSymbolicLink(),!n.followLinks&&h||!a.isDirectory())return[3,15];p=void 0,s.label=8;case 8:return s.trys.push([8,10,,11]),[4,(0,d.readdir)(i)];case 9:return p=b(p=s.sent().map((function(e){return(0,u.resolve)(i,e)})),n.sorted),[3,11];case 10:if(E=s.sent(),n.skipErrors)return[2,null];throw E;case 11:return y=t,p.length?[4,D(i,p,"\n ",n,1)]:[3,13];case 12:return I=s.sent(),[3,14];case 13:I="",s.label=14;case 14:t=y+I,s.label=15;case 15:return[2,t]}}))}))},r.parseTree=function(e,r){var t="",n=m(r);return(t+=e?e.name:"")+(e.children?F(e.children,"\n ",n,1):"")},r.parseTreeAsync=function(e,r){return n(this,void 0,void 0,(function(){var t,n,i,o;return s(this,(function(s){switch(s.label){case 0:return t="",n=m(r),t+=e?e.name:"",i=t,e.children?[4,_(e.children,"\n ",n,1)]:[3,2];case 1:return o=s.sent(),[3,3];case 2:o="",s.label=3;case 3:return[2,t=i+o]}}))}))}},756:e=>{e.exports=require("minimatch")},982:e=>{e.exports=require("crypto")},896:e=>{e.exports=require("fs")},943:e=>{e.exports=require("fs/promises")},857:e=>{e.exports=require("os")},928:e=>{e.exports=require("path")}},r={};return function t(n){var s=r[n];if(void 0!==s)return s.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(499)})()));
# [4.8.0](https://github.com/euberdeveloper/dree/compare/4.7.0...4.8.0) (2024-04-28)
### Features
* **bin:** add the post sort param ([1b0e72c](https://github.com/euberdeveloper/dree/commit/1b0e72c71956e6741eb0a5721a403a53112acdd2))
* **lib:** add post sort ([8e9c4a4](https://github.com/euberdeveloper/dree/commit/8e9c4a44b4129a21611aecbf0941513948a3f711))
# [4.7.0](https://github.com/euberdeveloper/dree/compare/4.6.4...4.7.0) (2024-02-19)

@@ -4,0 +12,0 @@

{
"name": "dree",
"version": "4.7.0",
"version": "4.8.0",
"description": "A nodejs module wich helps you handle a directory tree providing you its abstraction through tested functions and a custom configuration.",

@@ -5,0 +5,0 @@ "main": "bundled/lib/index.js",

@@ -395,3 +395,4 @@ ![Test](https://github.com/euberdeveloper/dree/workflows/Test/badge.svg)

* __descendantsIgnoreDirectories__: Default value `false`. If true, only files will be count as descendants of a node. It does not have effect if descendants option is not true.
* __sorted__: Default value: `undefined`. If true, directories and files will be scanned ordered by path. The value can be both boolean for default alpha order, a custom sorting function or a predefined sorting method in SortMethodPredefined.
* __sorted__: Default value: `false`. If true, directories and files will be scanned ordered by path. The value can be both boolean for default alpha order, a custom sorting function or a predefined sorting method in SortMethodPredefined.
* __postSorted__: Default value: `false`. If true, the child nodes of a node will be ordered. The value can be both boolean for default alpha order, a custom sorting function or a predefined sorting method in PostSortMethodPredefined.
* __homeShortcut__: Default value: `false`. If true, the unix homedir shortcut ~ will be expanded to the user home directory.

@@ -398,0 +399,0 @@ * __skipErrors__: Default value: `true`. If true, folders whose user has not permissions will be skipped. An error will be thrown otherwise. Note: in fact every error thrown by `fs` calls will be ignored.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc