Never Propel Marmalade


    1.0.0 • Public • Published

    stream-copy-dir The MIT License npm downloads

    Streaming copy of directory to destination - no globs and no recursion. In addition can pass a 'plugin' function to modify the contents of each file - perfect place for template engines.

    code climate standard code style travis build status coverage status dependency status


    Install with npm

    $ npm i stream-copy-dir --save


    For more use-cases see the tests

    const streamCopyDir = require('stream-copy-dir')



    Copy files from src to dest directory without globs and recursion. Can provide plugin function to modify file contents, which is useful for template engines. The plugin function gets two arguments - file and cb, where file is vinyl file and cb is optional, but it's recommended to pass the file like so cb(null, file)


    • <src> {String|Buffer}: source directory with files, passed to create-readdir-stream
    • <dest> {String|Buffer}: destination folder for (modified) files, passed to write-file
    • [plugin] {Function}: perfect place to access and modify contents of each file
    • returns {Stream}: transform stream, through2


    var copyFolder = require('stream-copy-dir')
    var handlebars = require('handlebars')
    function plugin (file, cb) {
      var contents = file.toString()
      var template = handlebars.compile(contents)
      contents = template({
        name: 'Charlike',
        baz: 'qux'
      // Buffer constructor is deprecated
      // so don't use `new Buffer` anymore in new code/projects
      // instead use `Buffer.from`
      file.contents = new Buffer(contents)
      cb(null, file)
    copyFolder('./src/templates', './my-project', plugin)
      .once('error', console.error)
      .once('finish', function () {
        console.log('copied and modified without errors')


    • always-done: Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions… more | homepage
    • callback2stream: Transform sync, async or generator function to Stream. Correctly handle errors and optional arguments. | homepage
    • create-readdir-stream: Streaming fs.readdir, extensible with smart plugins. No recursion and no globs by default - use plugins. Does… more | homepage
    • minibase: MiniBase is minimalist approach to Base - @node-base, the awesome framework. Foundation for building complex APIs with… more | homepage
    • promise2stream: Transform ES2015 Promise to Stream - specifically, Transform Stream using through2. Works in object mode by default… more | homepage
    • try-catch-core: Low-level package to handle completion and errors of sync or asynchronous functions, using once and dezalgo libs… more | homepage


    Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
    But before doing anything, please read the guidelines.

    Charlike Make Reagent new message to charlike freenode #charlike keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github


    npm i stream-copy-dir

    DownloadsWeekly Downloads






    Last publish


    • vanchoy
    • tunnckocore