Recursively mutates files in a given directory.
Last updated 7 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mutiny 
SYNC missed versions from official npm registry.

mutiny build status

Recursively mutates files in a given directory.

var through = require('through2');
var mutiny = require('mutiny');

function toUpper(file, content) {
  return through(
    function (chunk, enc, cb) {

var readdirpOpts = { root: __dirname + '/root' };
mutiny({ outdir: __dirname + '/out', transform: [ toUpper ]}, readdirpOpts)
  .on('error', console.error)
  .on('data', function (d) { console.log('\nProcessed:\n', d); })

transform example

# assuming trim-leading is a transform installed as a node_module
mutiny ./root -t ./local-transform/toUpper.js -t trim-leading -o ./out 

bin example


npm install mutiny


mutiny(mutinyopts, readopts) → {ReadStream}

Mutates the files of a directory recursively applying specified transform and/or a rename function. The transformed files are saved into the outdir and directory structure is maintained.

Name Type Description
mutinyopts Object
Name Type Description
outdir: String

the root of the directory to which to write the transformed/renamed files

transform: Array.<(function()|String)>

that transform each file's content

transform function signature: function(String):TransformStream

Note: each transform can be a function or a name of an installed transform or a path to a local module

rename: function

renames each file

signature: function ({String} outfile, {String} outdir, {String} relativeOutfile) : {String} outfile

getOutStream: function

allows overriding the defaultOutStream in case rename is not sufficient

signature: function ({String} outfile, {String} outdir, {String} relativeOutfile) : {WriteStream}

readopts Object

options passed through to readdirp

Name Type Description
root String

the root of the source directory that needs to be specified


which emits 'error' and or 'data' to update mutiny's progress


transformContent(progress, transforms)

Runs all transforms on the content of all files that are piped into its file stream. Reports progress by pushing into the @see progress stream.

Name Type Description
progress Stream

into which progress data is pushed

transforms Array.<function(String): Stream>

functions that return a transform stream when invoked with a path to a file - signature of each transform: function ({String} file) : {TransformStream}


generated with docme

More Examples

Please find more examples in the examples directory and consult the tests



Current Tags

  • 0.4.0                                ...           latest (7 years ago)

8 Versions

  • 0.4.0                                ...           7 years ago
  • 0.3.1                                ...           7 years ago
  • 0.3.0                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (6)
Dev Dependencies (2)

Copyright 2014 - 2016 © |