render-dir
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

render-dir

npm license travis status Build status Coverage Status David David Commitizen friendly NPM

Simple convenience function to help copy a source directory to a destinaton directory, with file contents being transformed.

Provides a promise based interface, that provides two things -

  1. A file path transformation
  2. A file content transformation

File Transformation

This is the raison d'etre for the library. Since different tools use different template engines, render-dir does not force an opinion.

The transformer() is invoked with the content of each file, allowing the user to provide the actual transformation logic, while getting a convenient promised interface to fs book-keeping

Installation

NOTE: We strongly prefer local installations versus global. Prevents most if not all occurances of "works-on-my-machine" symptom.

npm install render-dir
yarn install render-dir

Usage

renderDir is implmented as a simple API, but also exposed as an CLI, with the callback being provided in a javascript file, with the default export.

API

 
const renderDir = require('render-dir');
 
renderDir(srcdir: string, dstdir: string, transformer?: (fdesc: FileDescriptor) => FileDescriptor) => Promise<{}>

CLI

 
  Usage: render-dir [options] <srcdir> <dstdir>
 
  Applies transform & copies files from 'srcdir' -> 'dstdir', with filtering
 
 
  Options:
 
    -V, --version                output the version number
    -x, --transform <transform>  file with default exported function, used to transform file/content
    -h, --help                   output usage information
npx render-dir -x ./transform.js /src/template/dir/ /dst/dir/rendered/

Development Tooling

License

Apache-2.0

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Support

Bugs, PRs, comments, suggestions welcomed!

Dependencies (9)

Dev Dependencies (25)

Package Sidebar

Install

npm i render-dir

Weekly Downloads

0

Version

2.1.1

License

Apache-2.0

Last publish

Collaborators

  • sramam