Coder Social home page Coder Social logo

clean-dest's Introduction

clean-dest

GitHub

A CLI to clean a destination directory given a source directory.

Designed initially with typescript in mind, but can be used with any file types.

Install

$ npm install clean-dest

Usage

Folder structure

│
└───scripts
│   │   clean-dest.js
│
└───src
│   │   file1.ts
│   │   file2.ts
│
└───dist
│   │   file1.js
│   │   file1.js.map
│   │   file1.d.ts
│   │   file2.js
│   │   file2.js.map
│   │   file2.d.ts

Custom FileMap function

./scripts/clean-dest.js

module.exports = exports = {
    // Rename the file extensions from the 'ts' from the src folder to what we expect in the dest folder
    '.ts': (destFilePath) => [
        destFilePath.replace(/.ts$/, '.d.ts'),
        destFilePath.replace(/.ts$/, '.js'),
        destFilePath.replace(/.ts$/, '.js.map'),
    ]
};

CLI command

clean-dest -s ./src -d ./dist --file-map ./scripts/clean-dest

CLI

src-root

Glob pattern(s) for source files.

dest-root

Destination root directory.

base-pattern

An optional starting pattern to delete, default is "dest-root"/**/*.

file-map

Path to a js file whose only export is an extension to clean, or a [ext]: fn object to map source path to destination path(s).

permanent

Optional permanent delete using del, otherwise uses trash.

dry-run

Optional test run to not actually delete matched files.

verbose

Optional output logging.

API

See the API docs.

Watch Mode

Use nodemon:

nodemon --watch ./src -e ts --exec clean-dest -s ./src -d ./dist

clean-dest's People

Contributors

dependabot[bot] avatar seansobey avatar

Watchers

 avatar  avatar

Forkers

dobesv

clean-dest's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.