Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

test/fixtures/basic-images/expected/2013-11-25 18.59.52.jpg

8

History.md
0.0.4 - February 5, 2013
------------------------
* fix corrupted non-utf8 files
0.0.3 - February 5, 2013
------------------------
* expose `files` dictionary to `build` callback
0.0.2 - February 5, 2013

@@ -3,0 +11,0 @@ ------------------------

20

lib/index.js

@@ -9,2 +9,3 @@

var readdir = require('recursive-readdir');
var utf8 = require('is-utf8');
var Ware = require('ware');

@@ -111,3 +112,5 @@

if (err) return fn(err);
self.write(files, fn);
self.write(files, function(err){
fn(err, files);
});
});

@@ -136,8 +139,13 @@ });

function read(file, done){
fs.readFile(file, 'utf8', function(err, str){
var name = path.relative(dir, file);
fs.readFile(file, function(err, buffer){
if (err) return done(err);
var name = path.relative(dir, file);
var parsed = front(str);
files[name] = parsed.attributes;
files[name].body = parsed.body.trim();
if (utf8(buffer)) {
var parsed = front(buffer.toString());
files[name] = parsed.attributes;
files[name].body = parsed.body.trim();
} else {
files[name] = {};
files[name].body = buffer;
}
done();

@@ -144,0 +152,0 @@ });

{
"name": "metalsmith",
"repository": "git://github.com/segmentio/metalsmith.git",
"version": "0.0.2",
"version": "0.0.4",
"license": "MIT",

@@ -32,3 +32,4 @@ "description": "An extremely simple, pluggable static site generator.",

"fs-extra": "~0.8.1",
"defaults": "~1.0.0"
"defaults": "~1.0.0",
"is-utf8": "~0.2.0"
},

@@ -40,4 +41,5 @@ "devDependencies": {

"metalsmith-templates": "0.0.2",
"swig": "~1.3.2"
"swig": "~1.3.2",
"assert-dir-equal": "~0.1.0"
}
}
}
var assert = require('assert');
var equal = require('assert-dir-equal');
var exec = require('child_process').exec;

@@ -96,5 +97,6 @@ var fs = require('fs');

Metalsmith('test/fixtures/basic')
.build(function(err){
.build(function(err, files){
if (err) return done(err);
equal('basic/build', 'basic/expected');
assert.equal('object', typeof files);
equal('test/fixtures/basic/build', 'test/fixtures/basic/expected');
done();

@@ -104,2 +106,12 @@ });

it('should preserve binary files', function(done){
Metalsmith('test/fixtures/basic-images')
.build(function(err, files){
if (err) return done(err);
assert.equal('object', typeof files);
equal('test/fixtures/basic-images/build', 'test/fixtures/basic-images/expected');
done();
});
});
it('should apply a plugin', function(done){

@@ -116,3 +128,3 @@ Metalsmith('test/fixtures/basic-plugin')

if (err) return done(err);
equal('basic-plugin/build', 'basic-plugin/expected');
equal('test/fixtures/basic-plugin/build', 'test/fixtures/basic-plugin/expected');
done();

@@ -131,3 +143,3 @@ });

if (err) return done(err);
equal('cli-basic/build', 'cli-basic/expected');
equal('test/fixtures/cli-basic/build', 'test/fixtures/cli-basic/expected');
done();

@@ -140,3 +152,3 @@ });

if (err) return done(err);
equal('cli-json/destination', 'cli-json/expected');
equal('test/fixtures/cli-json/destination', 'test/fixtures/cli-json/expected');
done();

@@ -149,3 +161,3 @@ });

if (err) return done(err);
equal('cli-config/destination', 'cli-config/expected');
equal('test/fixtures/cli-config/destination', 'test/fixtures/cli-config/expected');
done();

@@ -158,3 +170,3 @@ });

if (err) return done(err);
equal('cli-source/destination', 'cli-source/expected');
equal('test/fixtures/cli-source/destination', 'test/fixtures/cli-source/expected');
done();

@@ -167,3 +179,3 @@ });

if (err) return done(err);
equal('cli-destination/overriden', 'cli-destination/expected');
equal('test/fixtures/cli-destination/overriden', 'test/fixtures/cli-destination/expected');
done();

@@ -176,3 +188,3 @@ });

if (err) return done(err);
equal('cli-templates/build', 'cli-templates/expected');
equal('test/fixtures/cli-templates/build', 'test/fixtures/cli-templates/expected');
done();

@@ -182,21 +194,2 @@ });

});
});
/**
* Assert a fixture build matches its expected contents.
*
* @param {String} one
* @param {String} two
*/
function equal(one, two){
one = 'test/fixtures/' + one;
two = 'test/fixtures/' + two;
readdir(one).forEach(function(rel){
var file = path.resolve(one, rel);
var other = path.resolve(two, rel);
file = fs.readFileSync(file, 'utf8');
other = fs.readFileSync(other, 'utf8');
assert.equal(file, other);
});
}
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc