Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 25, 2016
0 parents commit 5f2dbbc
Show file tree
Hide file tree
Showing 12 changed files with 687 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
*.log
.nyc_output/
coverage/
node_modules/
2 changes: 2 additions & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tests
ignored.md
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: node_js
node_js:
- '0.11'
- '0.12'
- '4.0'
- '5.0'
- '6.0'
after_success:
- bash <(curl -s https://codecov.io/bash)
deploy:
- provider: npm
email: tituswormer@gmail.com
api_key:
secure: WKR38P4F8NRJLV0ofVHbjqsg0vrvHhzChfQP30rnqbviMj9nG5qJGW9xbCQumjZLe7hLmGbAIowqrwu5NmMM4Rst4LhCbszfwL8Ud8eVhzUSH2cMaWhMLaQ4XR9hQbi/rbiVfyjhwaDLEAR1V2LjsDjE16pINy86nUUWQn/mEkJ9jzm3zJ5JZeO2lMOdpssMgt87S7sN02MJzJq9Epfh8lfjkEM/h5PAUF8EQMsmYNnZksfePVm5SJdnVQoF/JUZWcaVWozASsTjC3pvMKuptaMRc53MwSAxyIB00Gddcu2I4DgbdFEgQbFNAUGAkGorZ1HA8H0y/eioJhrkZfIijMqOxt9PJTxCvfpsnU+maNLne4vR6FrmrL0loSPbNAky62l1CM9DONUxb00UGCx+tnkwjwdkozghaTyzqd/MiGtluUYv6AxLmNNHZH1Nf/o44N92YZwxuNwA0TDah3EXoYLO+YRP54jdQz6EUA7SH2OfH/ypdJJ+jYGcn58CAhQ2D5dnKqBV3OulBAVsmnh6LkIxqYC8fIj+r+BU0rqtbCp52fJ8xUYFaphofdOTSx83BOXBxCoXa6DSnj2Pzm3bYx+qpSYpfBUo7FRnbuDNhr2QDE8UUaIwwEb1WynRRFuubyDe00cXGJoROlGxvM1096CPt/whhY+L11Pef4xSd3k=
on:
tags: true
node: '5.0'
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 6 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--remark setext-->

<!--lint disable no-multiple-toplevel-headings -->

0.0.0 / 2016-07-25
==================
118 changes: 118 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module unified-engine-gulp
* @fileoverview Create Gulp plug-ins for unified processors.
*/

'use strict';

/* Dependencies. */
var PassThrough = require('stream').PassThrough;
var engine = require('unified-engine');
var xtend = require('xtend');
var PluginError = require('gulp-util').PluginError;
var through = require('through2');
var convert = require('convert-vinyl-to-vfile');

/* Expose. */
module.exports = gulpEngine;

/**
* Create a Gulp plug-in.
*
* @param {Object} configuration - Configuration.
* @return {Function} - Gulp plug-in.
*/
function gulpEngine(configuration) {
var name = (configuration || {}).name;

if (!name) {
throw new Error('Expected `name` in `configuration`');
}

return plugin;

/**
* Plug-in.
*
* @param {Object?} options - Configuration.
* @param {TransformStream} - File stream.
*/
function plugin(options) {
var fileStream;
var config = xtend(options, configuration, {
injectedPlugins: [],
silentlyIgnore: true,
alwaysStringify: true,
output: false
});

/* Prevent some settings from being configured. */
config.cwd = config.globs = config.extensions = undefined;
config.out = config.streamIn = config.streamOut = undefined;

/**
* Handle virtual files.
*/
fileStream = through.obj(function (vinyl, encoding, callback) {
if (vinyl.isStream()) {
return callback(new PluginError(name, 'Streaming not supported'));
}

if (vinyl.isBuffer()) {
return buffer(vinyl, config, callback);
}

return callback(null, vinyl);
});

/* Patch. */
fileStream.use = use;

/* Return. */
return fileStream;

/**
* Inject plug-ins.
*
* See `injectedPlugins`:
* https://github.com/wooorm/unified-engine.
*/
function use() {
config.injectedPlugins.push([].slice.call(arguments));
return fileStream;
}
}
}

/**
* Handle a vinyl entry with buffer contents.
*
* @param {Vinyl} vinyl - Virtual file.
* @param {Object} opts - Configuration.
* @param {function} callback - Callback.
*/
function buffer(vinyl, opts, callback) {
var name = opts.name;
var vfile = convert(vinyl);

engine(xtend(opts, {
streamOut: new PassThrough(),
files: [vfile]
}), function (err, status) {
/* Skip ignored files. */
if (err && err.message === 'No input') {
return callback(null, vinyl);
}

if (err || status) {
return callback(new PluginError(name, err || 'Unsuccessful running'));
}

vinyl.contents = new Buffer(String(vfile), 'utf-8');

callback(null, vinyl);
});
}
71 changes: 71 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "unified-engine-gulp",
"version": "0.0.0",
"description": "Create Gulp plug-ins for unified processors",
"license": "MIT",
"keywords": [
"gulp",
"unified",
"processor"
],
"files": [
"index.js"
],
"repository": "https://github.com/wooorm/unified-engine-gulp",
"bugs": "https://github.com/wooorm/unified-engine-gulp/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
],
"dependencies": {
"convert-vinyl-to-vfile": "^0.1.1",
"gulp-util": "^3.0.7",
"through2": "^2.0.1",
"unified-engine": "^1.5.0",
"xtend": "^4.0.1"
},
"devDependencies": {
"nyc": "^7.0.0",
"remark": "^5.0.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-html": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-validate-links": "^4.0.0",
"tape": "^4.6.0",
"xo": "^0.16.0"
},
"scripts": {
"build": "remark *.md --quiet --frail",
"lint": "xo",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"xo": {
"space": true
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"remarkConfig": {
"output": true,
"plugins": {
"comment-config": null,
"github": null,
"lint": {
"heading-increment": false,
"no-duplicate-headings": false,
"list-item-spacing": false
},
"validate-links": null
},
"settings": {
"bullet": "*"
}
}
}
Loading

0 comments on commit 5f2dbbc

Please sign in to comment.