walkr
Recursive file walking / copying for node with middleware
Last updated 8 years ago by architectd .
Repository · Original npm · Tarball · package.json
$ cnpm install walkr 
SYNC missed versions from official npm registry.

Recursive file walking / copying for node.js with middleware

Motivation

  • Ability to filter files & directories.
  • Inspired by dryice, findit.

Copyr Example:

var walkFiles = require('walkr'),
fs            = require('fs'),
mu            = require('mu'),
tplData       = {};

walkFiles(source, destination).
filter(/^\./). //no hidden files AND dirs
filterDir(/node_modules/). //no node_modules dir
filterFile(function(options, next) {
	

	//template file? parse it, and copy it.
	if(options.source.match(/.tpl.html/)) {
		
		//after write file, call next. SINCE parameters are given, walkr assumes files were written, so it does
		//not continue.
		var tpl = mu.to_html(fs.readFileSync(options.source, "utf8"), tplData);
		return fs.writeFile(options.destination, tpl, next);

	}

	//call next without parameters 
	return next();
}).
filter(walkFiles.copy).
start(function(err) {
	
	//done
});

Walkr Example:

var walkFiles = require('walkr');

walkFiles(source).
on('directory', function(ops) {
	console.log(ops.source);
}).
on('file', function(ops) {
	console.log(ops.source);
}).
start(function(err) {
	
});

Current Tags

  • 0.0.3                                ...           latest (8 years ago)

3 Versions

  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (2)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (0)
None

Copyright 2014 - 2016 © taobao.org |