npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts-cleanup

v1.3.0

Published

A tool for cleaning up files built by typeScript

Downloads

280

Readme

ts-cleanup

NPM Version NPM Downloads Build Status Test Coverage DevDependencies

A 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.

Installation

$ npm install ts-cleanup --save

How to use it

Usage: ts-cleanup options

A tool for cleaning up files built by typeScript

Options:
  -s, --src <srcDir>    sets the source folder with ts files (required if -d not defined)
  -d, --dist <distDir>  sets the distribution folder with js files  (required if -s not defined)
  -v, --verbose         whether to show messages for files being deleted (disabled by default)
  -w, --watch           whether to watch for files being deleted (disabled by default)
  -a, --all             whether to remove all .js files
  -rd, --remove-dirs    whether to remove empty directories (default: true)
  -V, --version         output the current version
  -h, --help            output usage information
ts-cleanup -s src -d dist -v -rd

Node usage

ts-cleanup also provides two simple functions for usage from within a node script:

Basic usage

cleanup(src: string, dist: string, options?: ICleanSrcOptions);

  • src: the source folder with ts files (required if -d not defined)
  • dist: the distribution folder with js files (required if -s not defined)
  • options
    • root?: string: root directory
    • exclude?: string | string[]: pattern to exclude file matching
    • removeEmptyDirs?: boolean: whether to remove empty directories
    • verbose?: boolean: whether to show messages for files being deleted
const {cleanup} = require("ts-cleanup");

cleanup('./src', "./dis", {
  root: __dirname, // default process.cwd()
  removeAllJsFiles: true, // default false
  removeEmptyDirs: true, // default false
  verbose: true // default false
});
const {watch} = require("ts-cleanup");

watch('./src', "./dis", {
  root: __dirname, // default process.cwd()
  verbose: true // default false
});

watch(src: string, dist: string, options?: IWatchOptions);

  • src: the source folder with ts files (required if -d not defined)
  • dist: the distribution folder with js files (required if -s not defined)
  • options
    • root?: string: root directory
    • verbose?: boolean: whether to show messages for files being deleted

Advances usage

cleanSrc()

Cleans previously transpiled typescript files in a source directory.

cleanSrc(options?: ICleanSrcOptions, callback?: (filename: string) => boolean);

  • options
    • root?: string: root directory
    • exclude?: string | string[]: pattern to exclude file matching
    • removeAllJsFiles?: boolean: whether to remove all .js
    • removeEmptyDirs?: boolean: whether to remove empty directories
    • verbose?: boolean: whether to show messages for files being deleted
  • callback: executes this callback for each file, and removes only files wich callback returns true.
const {cleanSrc} = require("ts-cleanup");

cleanSrc({
  root: __dirname, // default process.cwd()
  removeAllJsFiles: true, // default false
  removeEmptyDirs: true, // default false
  verbose: true // default false
},  (f)=> f.includes('.spec.ts'));

cleanMatch()

Cleans any files that matches glob pattern.

cleanMatch(pattern: string | string[], options?: ICleanSrcOptions, callback?: (filename: string) => boolean);

  • pattern: Glob pattern to match files
  • options
    • root?: string: root directory
    • exclude?: string | string[]: pattern to exclude file matching
    • removeEmptyDirs?: boolean: whether to remove empty directories
    • verbose?: boolean: whether to show messages for files being deleted
  • callback: executes this callback for each file, and removes only files wich callback returns true.
const {cleanMatch} = require("ts-cleanup");

cleanMatch('src/**/*.spec.{js,js.map,d.ts}', {
  root: __dirname, // default process.cwd()
  removeEmptyDirs: true, // default false
  verbose: true // default false
},  (f)=> !f.includes('.dont-remove'));

Node Compatibility

  • node >= 8.0;

License

MIT