{"id":19124437,"url":"https://github.com/panates/ts-cleanup","last_synced_at":"2025-07-26T02:04:41.787Z","repository":{"id":42934773,"uuid":"236696223","full_name":"panates/ts-cleanup","owner":"panates","description":"A tool for cleaning up files built by typeScript","archived":false,"fork":false,"pushed_at":"2024-08-20T17:10:52.000Z","size":1415,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-01T05:33:36.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/panates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/package.cjs.json","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-28T09:10:40.000Z","updated_at":"2024-08-20T17:10:56.000Z","dependencies_parsed_at":"2024-08-09T16:42:57.519Z","dependency_job_id":"3847e997-9125-4438-bdf1-4b5001f09200","html_url":"https://github.com/panates/ts-cleanup","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":0.2195121951219512,"last_synced_commit":"f4e59aee8df49ab32a8889c8f40fac8312eb064c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fts-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fts-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fts-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fts-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panates","download_url":"https://codeload.github.com/panates/ts-cleanup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223789900,"owners_count":17203274,"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":[],"created_at":"2024-11-09T05:29:09.700Z","updated_at":"2024-11-09T05:29:10.390Z","avatar_url":"https://github.com/panates.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-cleanup\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![DevDependencies][devdependencies-image]][devdependencies-url]\n\nA helper script that can be used to cleanup previously transpiled typescript files. When typescript is setup to transpile files from a source to distribution folder, it won't automatically remove distribution files when their source file is deleted. ts-cleanup can take care of this task for you, both in single time build mode, or in watch mode.\n\n## Installation\n\n`$ npm install ts-cleanup --save`\n\n## How to use it\n\n```\nUsage: ts-cleanup options\n\nA tool for cleaning up files built by typeScript\n\nOptions:\n  -s, --src \u003csrcDir\u003e    sets the source folder with ts files (required if -d not defined)\n  -d, --dist \u003cdistDir\u003e  sets the distribution folder with js files  (required if -s not defined)\n  -v, --verbose         whether to show messages for files being deleted (disabled by default)\n  -w, --watch           whether to watch for files being deleted (disabled by default)\n  -a, --all             whether to remove all .js files\n  -rd, --remove-dirs    whether to remove empty directories (default: true)\n  -V, --version         output the current version\n  -h, --help            output usage information\n```\n\n```shell script\nts-cleanup -s src -d dist -v -rd\n```\n\n## Node usage\n\nts-cleanup also provides two simple functions for usage from within a node script:\n\n### Basic usage\n\n`cleanup(src: string, dist: string, options?: ICleanSrcOptions);`\n\n- `src`: the source folder with ts files (required if -d not defined)\n- `dist`: the distribution folder with js files  (required if -s not defined)\n- `options` \n    - `root?: string`: root directory\n    - `exclude?: string | string[]`: pattern to exclude file matching\n    - `removeEmptyDirs?: boolean`: whether to remove empty directories\n    - `verbose?: boolean`: whether to show messages for files being deleted\n\n```js\nconst {cleanup} = require(\"ts-cleanup\");\n\ncleanup('./src', \"./dis\", {\n  root: __dirname, // default process.cwd()\n  removeAllJsFiles: true, // default false\n  removeEmptyDirs: true, // default false\n  verbose: true // default false\n});\n```\n\n```js\nconst {watch} = require(\"ts-cleanup\");\n\nwatch('./src', \"./dis\", {\n  root: __dirname, // default process.cwd()\n  verbose: true // default false\n});\n```\n\n`watch(src: string, dist: string, options?: IWatchOptions);`\n\n- `src`: the source folder with ts files (required if -d not defined)\n- `dist`: the distribution folder with js files  (required if -s not defined)\n- `options` \n    - `root?: string`: root directory\n    - `verbose?: boolean`: whether to show messages for files being deleted\n\n\n### Advances usage\n\n\n#### cleanSrc()\n\nCleans previously transpiled typescript files in a source directory.\n\n`cleanSrc(options?: ICleanSrcOptions, callback?: (filename: string) =\u003e boolean);`\n\n- `options` \n    - `root?: string`: root directory\n    - `exclude?: string | string[]`: pattern to exclude file matching\n    - `removeAllJsFiles?: boolean`: whether to remove all .js\n    - `removeEmptyDirs?: boolean`: whether to remove empty directories\n    - `verbose?: boolean`: whether to show messages for files being deleted\n- `callback`: executes this callback for each file, and removes only files wich callback returns true. \n\n```js\nconst {cleanSrc} = require(\"ts-cleanup\");\n\ncleanSrc({\n  root: __dirname, // default process.cwd()\n  removeAllJsFiles: true, // default false\n  removeEmptyDirs: true, // default false\n  verbose: true // default false\n},  (f)=\u003e f.includes('.spec.ts'));\n```\n\n#### cleanMatch()\n\nCleans any files that matches glob pattern.\n\n`cleanMatch(pattern: string | string[], options?: ICleanSrcOptions, callback?: (filename: string) =\u003e boolean);`\n\n- `pattern`: Glob pattern to match files\n- `options` \n    - `root?: string`: root directory\n    - `exclude?: string | string[]`: pattern to exclude file matching\n    - `removeEmptyDirs?: boolean`: whether to remove empty directories\n    - `verbose?: boolean`: whether to show messages for files being deleted\n- `callback`: executes this callback for each file, and removes only files wich callback returns true. \n\n```js\nconst {cleanMatch} = require(\"ts-cleanup\");\n\ncleanMatch('src/**/*.spec.{js,js.map,d.ts}', {\n  root: __dirname, // default process.cwd()\n  removeEmptyDirs: true, // default false\n  verbose: true // default false\n},  (f)=\u003e !f.includes('.dont-remove'));\n```\n\n## Node Compatibility\n\n  - node `\u003e= 8.0`;\n  \n### License\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ts-cleanup.svg\n[npm-url]: https://npmjs.org/package/ts-cleanup\n[travis-image]: https://img.shields.io/travis/panates/ts-cleanup/master.svg\n[travis-url]: https://travis-ci.org/panates/ts-cleanup\n[coveralls-image]: https://img.shields.io/coveralls/panates/ts-cleanup/master.svg\n[coveralls-url]: https://coveralls.io/r/panates/ts-cleanup\n[downloads-image]: https://img.shields.io/npm/dm/ts-cleanup.svg\n[downloads-url]: https://npmjs.org/package/ts-cleanup\n[devdependencies-image]: https://david-dm.org/panates/ts-cleanup/dev-status.svg\n[devdependencies-url]:https://david-dm.org/panates/ts-cleanup?type=dev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanates%2Fts-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanates%2Fts-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanates%2Fts-cleanup/lists"}