Comparing version 2.0.0 to 3.0.0
62
index.js
'use strict'; | ||
var extend = require('util')._extend; | ||
var through = require('through2'); | ||
var pug = require('pug'); | ||
var extend = require('util-extend'); | ||
var gutil = require('gulp-util'); | ||
var replaceExtension = gutil.replaceExtension; | ||
var PluginError = gutil.PluginError; | ||
var defaultPug = require('pug'); | ||
var ext = require('gulp-util').replaceExtension; | ||
var PluginError = require('gulp-util').PluginError; | ||
module.exports = function gulpPug(opts) { | ||
var baseOpts = extend({}, opts); | ||
module.exports = function gulpPug(options) { | ||
var opts = extend({}, options); | ||
var pug = opts.pug || opts.jade || defaultPug; | ||
return through.obj(function(file, enc, callback) { | ||
var error = null; | ||
return through.obj(function compilePug(file, enc, cb) { | ||
opts.filename = file.path; | ||
// Prepare new file. | ||
var html = file.clone(); | ||
html.path = replaceExtension(html.path, '.html'); | ||
// Create options for pug. | ||
var opts = extend({ | ||
filename: file.path | ||
}, baseOpts); | ||
// Locals | ||
opts.data = opts.data || {}; | ||
var data = opts.data; | ||
if (file.data) { | ||
data = extend(data, file.data); | ||
opts.data = file.data; | ||
} | ||
// Custom pug module | ||
if (opts.pug) { | ||
pug = opts.pug; | ||
file.path = ext(file.path, opts.client ? '.js' : '.html'); | ||
if (file.isStream()) { | ||
return cb(new PluginError('gulp-pug', 'Streaming not supported')); | ||
} | ||
// Replace contents | ||
if (html.isBuffer()) { | ||
if (file.isBuffer()) { | ||
try { | ||
var contents = pug.compile(file.contents.toString(), opts)(data); | ||
html.contents = new Buffer(contents); | ||
} catch (err) { | ||
error = new PluginError('gulp-pug', err); | ||
var compiled; | ||
var contents = String(file.contents); | ||
if (opts.client) { | ||
compiled = pug.compileClient(contents, opts); | ||
} else { | ||
compiled = pug.compile(contents, opts)(opts.locals || opts.data); | ||
} | ||
file.contents = new Buffer(compiled); | ||
} catch (e) { | ||
return cb(new PluginError('gulp-pug', e)); | ||
} | ||
} else { | ||
error = new PluginError('gulp-pug', 'Unsupported file content'); | ||
} | ||
// Continue | ||
callback(error, error ? null : html); | ||
cb(null, file); | ||
}); | ||
}; |
{ | ||
"name": "gulp-pug", | ||
"version": "2.0.0", | ||
"description": "Gulp plugin for compiling Pug templates.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "eslint index.js test; ava -t | tap-spec" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jamen/gulp-pug.git" | ||
}, | ||
"version": "3.0.0", | ||
"description": "Compile Pug templates", | ||
"keywords": [ | ||
"gulp", | ||
"jade", | ||
"pug", | ||
"gulpplugin", | ||
"pugjs" | ||
"stream", | ||
"compile" | ||
], | ||
"author": "Jamen Marzonie <jamenmarz@gmail.com> (http://jamenmarz.com/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jamen/gulp-pug/issues" | ||
"repository": "https://github.com/jamen/gulp-pug.git", | ||
"dependencies": { | ||
"gulp-util": "^3.0.2", | ||
"pug": "^2.0.0-alpha6", | ||
"through2": "^2.0.0" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"LICENSE" | ||
], | ||
"homepage": "https://github.com/jamen/gulp-pug#readme", | ||
"engines": { | ||
"node": ">= 0.10" | ||
}, | ||
"scripts": { | ||
"test": "gulp eslint && tap ./test" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"ava": "^0.14.0", | ||
"eslint": "^2.7.0", | ||
"eslint-config-google": "^0.4.0", | ||
"gulp": "^3.9.1", | ||
"gulp-data": "^1.2.1", | ||
"precommit": "^1.2.0", | ||
"tap-spec": "^4.1.1" | ||
}, | ||
"dependencies": { | ||
"gulp-util": "^3.0.7", | ||
"pug": "latest", | ||
"through2": "^2.0.1", | ||
"util-extend": "^1.0.3" | ||
"eslint-config-google": "^0.5.0", | ||
"eslint-config-xo": "^0.14.1", | ||
"gulp": "^3.8.10", | ||
"gulp-eslint": "^2.0.0", | ||
"tap": "^1.3.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
5
3013
3
35
2
1
1
0
1
+ Added@types/babel-types@7.0.15(transitive)
+ Added@types/babylon@6.16.9(transitive)
+ Addedacorn@3.3.04.0.13(transitive)
+ Addedacorn-globals@3.1.0(transitive)
+ Addedalign-text@0.1.4(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbabel-types@6.26.0(transitive)
+ Addedbabylon@6.18.0(transitive)
+ Addedcamelcase@1.2.1(transitive)
+ Addedcenter-align@0.1.3(transitive)
+ Addedclean-css@4.2.4(transitive)
+ Addedcliui@2.1.0(transitive)
+ Addedconstantinople@3.1.2(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-expression@3.0.0(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addedlazy-cache@1.0.4(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlongest@1.0.1(transitive)
+ Addedpug@2.0.4(transitive)
+ Addedpug-attrs@2.0.4(transitive)
+ Addedpug-code-gen@2.0.3(transitive)
+ Addedpug-error@1.3.3(transitive)
+ Addedpug-filters@3.1.1(transitive)
+ Addedpug-lexer@4.1.0(transitive)
+ Addedpug-linker@3.0.6(transitive)
+ Addedpug-load@2.0.12(transitive)
+ Addedpug-parser@5.0.1(transitive)
+ Addedpug-runtime@2.0.5(transitive)
+ Addedpug-strip-comments@1.0.4(transitive)
+ Addedpug-walk@1.1.8(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedright-align@0.1.3(transitive)
+ Addedsource-map@0.5.70.6.1(transitive)
+ Addedto-fast-properties@1.0.3(transitive)
+ Addedtoken-stream@0.0.1(transitive)
+ Addeduglify-js@2.8.29(transitive)
+ Addeduglify-to-browserify@1.0.2(transitive)
+ Addedvoid-elements@2.0.1(transitive)
+ Addedwindow-size@0.1.0(transitive)
+ Addedwith@5.1.1(transitive)
+ Addedwordwrap@0.0.2(transitive)
+ Addedyargs@3.10.0(transitive)
- Removedutil-extend@^1.0.3
- Removed@babel/helper-string-parser@7.24.8(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/parser@7.25.6(transitive)
- Removed@babel/types@7.25.6(transitive)
- Removedacorn@7.4.1(transitive)
- Removedassert-never@1.3.0(transitive)
- Removedbabel-walk@3.0.0-canary-5(transitive)
- Removedconstantinople@4.0.1(transitive)
- Removedis-expression@4.0.0(transitive)
- Removedpug@3.0.3(transitive)
- Removedpug-attrs@3.0.0(transitive)
- Removedpug-code-gen@3.0.3(transitive)
- Removedpug-error@2.1.0(transitive)
- Removedpug-filters@4.0.0(transitive)
- Removedpug-lexer@5.0.1(transitive)
- Removedpug-linker@4.0.0(transitive)
- Removedpug-load@3.0.0(transitive)
- Removedpug-parser@6.0.0(transitive)
- Removedpug-runtime@3.0.1(transitive)
- Removedpug-strip-comments@2.0.0(transitive)
- Removedpug-walk@2.0.0(transitive)
- Removedto-fast-properties@2.0.0(transitive)
- Removedtoken-stream@1.0.0(transitive)
- Removedutil-extend@1.0.3(transitive)
- Removedvoid-elements@3.1.0(transitive)
- Removedwith@7.0.2(transitive)
Updatedgulp-util@^3.0.2
Updatedpug@^2.0.0-alpha6
Updatedthrough2@^2.0.0