jelz / gulp-metalsmith Goto Github PK
View Code? Open in Web Editor NEWLightweight gulp plugin for Metalsmith
Lightweight gulp plugin for Metalsmith
I am in the process of converting an existing Metalsmith site to be built with gulp-metalsmith, but am running into the File.contents error. From the trace I am given, it seems to be coming from the pushToStream method in /lib/index.js
.
Error: File.contents can only be a Buffer, a Stream, or null.
at File.set (/my_project/node_modules/vinyl/index.js:148:13)
at baseAssignValue (/my_project/node_modules/lodash/lodash.js:2580:21)
at assignValue (/my_project/node_modules/lodash/lodash.js:2496:9)
at copyObject (/my_project/node_modules/lodash/lodash.js:4819:11)
at /my_project/node_modules/lodash/lodash.js:12653:7
at Function.<anonymous> (/my_project/node_modules/lodash/lodash.js:4892:13)
at apply (/my_project/node_modules/lodash/lodash.js:496:27)
at Function.<anonymous> (/my_project/node_modules/lodash/lodash.js:6600:16)
at /my_project/node_modules/gulp-metalsmith/lib/index.js:91:16
at /my_project/node_modules/lodash/lodash.js:4944:15
at baseForOwn (/my_project/node_modules/lodash/lodash.js:3001:24)
at Function.forOwn (/my_project/node_modules/lodash/lodash.js:13002:24)
at pushToStream (/my_project/node_modules/gulp-metalsmith/lib/index.js:87:7)
at /my_project/node_modules/gulp-metalsmith/lib/index.js:79:9
at next (/my_project/node_modules/ware/lib/index.js:82:27)
at /my_project/node_modules/wrap-fn/index.js:121:18
I have modified the file locally to resolve the issue as follows:
function pushToStream(transformed) {
_.forOwn(transformed, function (value, key) {
var file = value._vinyl || new gutil.File({stat: value.stat});
file.path = path.join(file.base, key);
s.push(_.extend(file, {contents: typeof value.contents === 'string' ? new Buffer(value.contents) : value.contents}));
// Original Code: s.push(_.extend(file, {contents: value.contents}));
});
}
While this solves the issue, I am not sure I have a strong argument that this is a bug in the plugin as it seems no one else has reported similar issues. My current build works fine with the same set of Metalsmith plugins generating the same files without error.
Is this something you would me to create a PR for? If not, do you have any thoughts as to what may be going wrong?
I have a local installation of npm and gulp under ./metalsmith/security/
My striped gulpfile.js
looks like this:
var metalsmith = require('metalsmith'); //also tried require('..'); -> same output
var gulp = require('gulp');
var glob = require('glob');
var path = require('path');
gulp.task('default', function() {
return gulp.src('../../sourceRepo')
.pipe(metalsmith())
.pipe(gulp.dest('../../build'));
});
This throws an AssertionError: You must pass a working directory path.
error.
Apparently `require('metasmith') is wrong. What should I add there?
EDIT:
I had a typo in the first line: var Metalsmith -> var metalsmith
This throws "AssertionError: You must pass a working directory path."
First of all, thanks for the great tool. It has been a tremendous help and enables some truly graceful workflows.
I ran into an issue where my images were not being copied over to the build
directory correctly; I narrowed the pipeline
issue down to gulp-metalsmith
.
Without knowing any specifics, I can say that both my .ico
and .png
files are somehow corrupted. Although copied over, no image viewer is able to display them, including the browser.
For now, I use gulp-filter to modify and restore the vinyl
pipe before and after the gulp-metalsmith
step, but it would be nice if I could avoid that additional step.
Thank you for your time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.