| 'use strict'; | ||
| var PluginError = require('plugin-error'); | ||
| var isBinary = require('file-is-binary'); | ||
| var through = require('through2'); | ||
| exports.trim = function() { | ||
| return plugin(function(file, next) { | ||
| file.contents = new Buffer(file.contents.toString().trim() + '\n'); | ||
| next(null, file); | ||
| }); | ||
| }; | ||
| exports.wrapFrame = function(props) { | ||
| return plugin(function(file, next) { | ||
| var str = file.contents.toString(); | ||
| if (str.slice(0, 3) !== '---') { | ||
| var hash = props.map(function(prop) { | ||
| return prop + '=' + prop; | ||
| }); | ||
| str = `{{#frame ${hash.join(' ')}}}\n` + str.trim() + '\n{{/frame}}\n'; | ||
| file.contents = new Buffer(str); | ||
| } | ||
| next(null, file); | ||
| }); | ||
| }; | ||
| exports.format = function() { | ||
| return plugin(function(file, next) { | ||
| var str = file.contents.toString(); | ||
| // fix main `styles.css` path | ||
| str = str.replace(/\/(?=styles\.css)/, '/assets/css/'); | ||
| // strip leading indentation before {{markdown}} tags | ||
| str = str.replace(/^\s+(\{\{(\/|#)?(?:markdown|md))/gm, '$1'); | ||
| file.contents = new Buffer(str); | ||
| next(null, file); | ||
| }); | ||
| }; | ||
| exports.normalizeNewlines = function() { | ||
| return plugin(function(file, next) { | ||
| var str = file.contents.toString(); | ||
| file.contents = new Buffer(str.replace(/\r\n/g, '\n')); | ||
| next(null, file); | ||
| }); | ||
| }; | ||
| exports.addImport = function(options) { | ||
| return plugin(function(file, next) { | ||
| if (!options || typeof options.addImport !== 'string') { | ||
| next(null, file); | ||
| return; | ||
| } | ||
| var str = file.contents.toString().trim(); | ||
| file.contents = new Buffer(str + `\n@import "${options.addImport}";\n`); | ||
| next(null, file); | ||
| }); | ||
| }; | ||
| exports.stripEmptyMatter = function() { | ||
| return plugin(function(file, next) { | ||
| var str = file.contents.toString(); | ||
| if (str.slice(0, 8) === '---\n---\n') { | ||
| file.contents = new Buffer(str.slice(8)); | ||
| } | ||
| next(null, file); | ||
| }); | ||
| }; | ||
| function plugin(fn) { | ||
| return through.obj(function(file, enc, next) { | ||
| try { | ||
| if (isBinary(file) || file.isNull()) { | ||
| next(null, file); | ||
| return; | ||
| } | ||
| fn(file, next); | ||
| } catch (err) { | ||
| err.fn = fn; | ||
| this.emit('error', new PluginError('hekyll', err, {showStack: true})); | ||
| next(err); | ||
| } | ||
| }); | ||
| } |
+33
| 'use strict'; | ||
| const path = require('path'); | ||
| exports.isPromise = function(val) { | ||
| return val && typeof val.then === 'function'; | ||
| }; | ||
| exports.toDest = function(options) { | ||
| return function(file) { | ||
| file.extname = file.extname.replace(/liquid/, 'hbs'); | ||
| return path.resolve(options.destBase, options.dest(file)); | ||
| }; | ||
| }; | ||
| exports.toOptions = function(app, options, dest) { | ||
| if (typeof options === 'function') { | ||
| dest = options; | ||
| options = null; | ||
| } | ||
| const defaults = {allowEmpty: true, dot: true, nocase: true, dest: dest}; | ||
| const opts = Object.assign({}, defaults, app.options, options); | ||
| if (typeof opts.dest !== 'function') { | ||
| return Promise.reject(new TypeError('expected options.dest to be a function')); | ||
| } | ||
| if (typeof opts.destBase !== 'string') { | ||
| return Promise.reject(new TypeError('expected options.destBase to be a string')); | ||
| } | ||
| if (typeof opts.cwd !== 'string') { | ||
| return Promise.reject(new TypeError('expected options.cwd to be a string')); | ||
| } | ||
| return opts; | ||
| }; |
+1
-1
@@ -21,2 +21,2 @@ The MIT License (MIT) | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
| THE SOFTWARE. |
+3
-2
| { | ||
| "name": "hekyll", | ||
| "description": "Migrate Jekyll (gh-pages) themes to use handlebars instead of liquid.", | ||
| "version": "3.0.0", | ||
| "version": "3.0.1", | ||
| "homepage": "https://github.com/jonschlinkert/hekyll", | ||
@@ -13,3 +13,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
| "files": [ | ||
| "index.js" | ||
| "index.js", | ||
| "lib" | ||
| ], | ||
@@ -16,0 +17,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20547
18.91%7
40%301
53.57%0
-100%