Skip to content

Commit

Permalink
Merge 781a602 into f368c7d
Browse files Browse the repository at this point in the history
  • Loading branch information
woodyrew committed Aug 12, 2016
2 parents f368c7d + 781a602 commit 16e9c85
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_js:
- "iojs"
- "4"
- "5"
- "6"
- "node"

matrix:
Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [2.2.0] - August 11, 2016
### Added
* add support for function ignore matchers ([#179])
* Add support for function ignore matchers ([#179])
* Exposing ignore to CLI ([#232])
* `process` to process files and plugins without writing files out. ([#244])

### Changed
* only remove contents of destination directory (not the directory itself) when
`clean` is true ([#221])

[#179]: https://github.com/metalsmith/metalsmith/issues/179
[#221]: https://github.com/metalsmith/metalsmith/pull/221
[#232]: https://github.com/metalsmith/metalsmith/pull/232
[#244]: https://github.com/metalsmith/metalsmith/pull/244


## [2.1.0] - September 24, 2015
Expand Down Expand Up @@ -227,7 +231,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
:sparkles:


[Unreleased]: https://github.com/metalsmith/metalsmith/compare/v2.1.0...HEAD
[2.2.0]: https://github.com/metalsmith/metalsmith/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/metalsmith/metalsmith/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/metalsmith/metalsmith/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/metalsmith/metalsmith/compare/v1.7.0...v2.0.0
Expand Down
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ Resolve any amount of `paths...` relative to the working directory. This is usef

Run all of the middleware functions on a dictionary of `files` and callback with `fn(err, files)`, where `files` is the altered dictionary.

#### #process(fn)

Process the files like build without writing any files. Callback signature `fn(err, files)`.

## Metadata API

Expand Down
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ Metalsmith.prototype.build = unyield(function*(){
var dest = this.destination();
if (clean) yield rm(path.join(dest, '*'));

var files = yield this.read();
files = yield this.run(files);
var files = yield this.process();
yield this.write(files);
return files;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metalsmith",
"version": "2.1.0",
"version": "2.2.0",
"license": "MIT",
"repository": "git://github.com/segmentio/metalsmith.git",
"description": "An extremely simple, pluggable static site generator.",
Expand Down
36 changes: 36 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,42 @@ describe('Metalsmith', function(){
});
});

describe('#process', function(){
it('should return files object with no plugins', function(done){
Metalsmith(fixture('basic'))
.process(function(err, files){
if (err) return done(err);
assert.equal(typeof files, 'object');
assert.equal(typeof files['index.md'], 'object');
assert.equal(files['index.md'].title, 'A Title');
assert.equal(typeof files['nested/index.md'], 'object');
done();
});
});
it('should apply a plugin', function(done){
Metalsmith(fixture('basic-plugin'))
.use(function(files, metalsmith, done){
Object.keys(files).forEach(function(file){
var data = files[file];
data.contents = new Buffer(data.title);
});
done();
})
.process(function(err, files){
if (err) return done(err);
assert.equal(typeof files, 'object');
assert.equal(Object.keys(files).length, 2);
assert.equal(typeof files['one.md'], 'object');
assert.equal(files['one.md'].title, 'one');
assert.equal(files['one.md'].contents.toString('utf8'), 'one');
assert.equal(typeof files['two.md'], 'object');
assert.equal(files['two.md'].title, 'two');
assert.equal(files['two.md'].contents.toString('utf8'), 'two');
done();
});
});
});

describe('#build', function(){
it('should do a basic copy with no plugins', function(done){
Metalsmith(fixture('basic'))
Expand Down

0 comments on commit 16e9c85

Please sign in to comment.