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 -
- A file path transformation
- A file content 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
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
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.
const renderDir = require('render-dir');
renderDir(srcdir: string, dstdir: string, transformer?: (fdesc: FileDescriptor) => FileDescriptor) => Promise<{}>
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/
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.
Bugs, PRs, comments, suggestions welcomed!