{"id":19750143,"url":"https://github.com/lqmanh/directory-stat","last_synced_at":"2025-04-30T10:30:43.430Z","repository":{"id":33545392,"uuid":"159353337","full_name":"lqmanh/directory-stat","owner":"lqmanh","description":"Composable directory statistics fetcher where \"fs\" is insufficient","archived":false,"fork":false,"pushed_at":"2023-03-01T00:57:04.000Z","size":553,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-01-24T05:01:44.432Z","etag":null,"topics":["dir","directory","stat","statistics"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lqmanh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-27T15:03:23.000Z","updated_at":"2024-01-24T05:01:44.433Z","dependencies_parsed_at":"2023-02-17T00:05:17.302Z","dependency_job_id":null,"html_url":"https://github.com/lqmanh/directory-stat","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lqmanh%2Fdirectory-stat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lqmanh%2Fdirectory-stat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lqmanh%2Fdirectory-stat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lqmanh%2Fdirectory-stat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lqmanh","download_url":"https://codeload.github.com/lqmanh/directory-stat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224205988,"owners_count":17273374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dir","directory","stat","statistics"],"created_at":"2024-11-12T02:30:47.221Z","updated_at":"2024-11-12T02:33:00.316Z","avatar_url":"https://github.com/lqmanh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/github/license/lqmanh/directory-stat.svg?style=flat-square)](https://github.com/lqmanh/directory-stat)\n[![](https://img.shields.io/npm/v/directory-stat.svg?style=flat-square)](https://www.npmjs.com/package/directory-stat)\n\n# directory-stat\n\n\u003e Composable directory statistics fetcher where \"fs\" is insufficient\n\n## INSTALLATION\n\n### Requirements\n\n- Node.js \u003e= v8.0.0\n\n### Instructions\n\n_Notice:_\n\n- To use **directory-stat** as a standalone CLI app, you should install the package globally.\n- To take advantages of all advanced features like custom statistics collectors, you need to use **directory-stat** as a library.\n\n#### With `npm`\n\n```\n$ npm install directory-stat\n```\n\nor\n\n```\n$ npm install -g directory-stat\n```\n\n#### With `yarn`\n\n```\n$ yarn add directory-stat\n```\n\nor\n\n```\n$ yarn global add directory-stat\n```\n\n## USAGE\n\n### As a Standalone CLI App\n\nUse `-h, --help` flag to see more:\n\n```bash\n$ directory-stat --help\nComposable directory statistics fetcher where \"fs\" is insufficient\n\nUSAGE\n  $ directory-stat DIR\n\nARGUMENTS\n  DIR  directory\n\nOPTIONS\n  -d, --depth=depth      [default: -1] how deep in directory tree statistics\n                         should be fetched. Unlimited if \u003c 0\n\n  -h, --help             show CLI help\n\n  -m, --[no-]minified    minify output\n\n  -o, --output=output    [default: .dirstat] name of the output file\n\n  -v, --version          show CLI version\n\n  -x, --exclude=exclude  [default: ] ignore any children matching this glob\n\n  --[no-]size            include size (in bytes)\n\n  --[no-]timestamp       include timestamp\n\n  --[no-]type            include type\n\nDESCRIPTION\n  Fetch directory statistics then save to a JSON file in that directory\n```\n\n### As a Library\n\nExample:\n\n```javascript\nconst fs = require('fs').promises // Node.js \u003e= 10.0.0\nconst path = require('path')\n\nconst { StatWriter } = require('directory-stat')\nconst { StatCollector } = require('directory-stat/stat-collectors')\n\nclass FileContentCollector extends StatCollector {\n  constructor() {\n    super('content')\n  }\n\n  async collect(pathStr, stat) {\n    if (!stat.isFile()) return undefined\n    return fs.readFile(pathStr, { encoding: 'utf8' })\n  }\n}\n\nconst statWriter = new StatWriter(path.join(__dirname, 'example'), {\n  depth: 1,\n  exclude: ['.dirstat', 'dirstat.json'],\n  output: 'dirstat.json',\n  statCollectors: [new FileContentCollector()]\n})\nstatWriter.export().then(() =\u003e console.log('Done'))\n```\n\n## CHANGELOG\n\nRead more [here](https://github.com/lqmanh/directory-stat/blob/master/CHANGELOG.md).\n\n## TODO\n\nRead more [here](https://github.com/lqmanh/directory-stat/blob/master/TODO.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flqmanh%2Fdirectory-stat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flqmanh%2Fdirectory-stat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flqmanh%2Fdirectory-stat/lists"}