gulp-preprocess
Advanced tools
| { | ||
| "extends": "eslint:recommended", | ||
| "env": { | ||
| "node": true, | ||
| "mocha": true | ||
| } | ||
| } |
+1
-1
| language: node_js | ||
| node_js: | ||
| - "0.10" | ||
| - 10 |
+15
-12
@@ -1,8 +0,8 @@ | ||
| var _ = require('lodash'); | ||
| var map = require('map-stream'); | ||
| var pp = require('preprocess'); | ||
| var path = require('path'); | ||
| var _ = require("lodash"); | ||
| var map = require("map-stream"); | ||
| var pp = require("preprocess"); | ||
| var path = require("path"); | ||
| module.exports = function (options) { | ||
| var opts = _.merge({}, options); | ||
| module.exports = function(options) { | ||
| var opts = _.merge({}, options); | ||
| var context = _.merge({}, process.env, opts.context); | ||
@@ -15,13 +15,16 @@ | ||
| if (file.isNull()) return callback(null, file); // pass along | ||
| if (file.isStream()) return callback(new Error("gulp-preprocess: Streaming not supported")); | ||
| if (file.isStream()) | ||
| return callback(new Error("gulp-preprocess: Streaming not supported")); | ||
| context.src = file.path; | ||
| context.srcDir = opts.includeBase || path.dirname(file.path); | ||
| context.NODE_ENV = context.NODE_ENV || 'development'; | ||
| context.NODE_ENV = context.NODE_ENV || "development"; | ||
| extension = _.isEmpty(opts.extension) ? getExtension(context.src) : opts.extension; | ||
| extension = _.isEmpty(opts.extension) | ||
| ? getExtension(context.src) | ||
| : opts.extension; | ||
| contents = file.contents.toString('utf8'); | ||
| contents = file.contents.toString("utf8"); | ||
| contents = pp.preprocess(contents, context, extension); | ||
| file.contents = new Buffer(contents); | ||
| file.contents = Buffer.from(contents); | ||
@@ -35,4 +38,4 @@ callback(null, file); | ||
| function getExtension(filename) { | ||
| var ext = path.extname(filename||'').split('.'); | ||
| var ext = path.extname(filename || "").split("."); | ||
| return ext[ext.length - 1]; | ||
| } |
+9
-7
| { | ||
| "name": "gulp-preprocess", | ||
| "description": "Gulp plugin to preprocess HTML, JavaScript, and other files based on custom context or environment configuration", | ||
| "version": "2.0.0", | ||
| "homepage": "http://github.com/jas/gulp-preprocess", | ||
| "version": "3.0.0", | ||
| "homepage": "http://github.com/pioug/gulp-preprocess", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "http://github.com/jas/gulp-preprocess.git" | ||
| "url": "http://github.com/pioug/gulp-preprocess.git" | ||
| }, | ||
@@ -13,3 +13,3 @@ "author": "Jason Sandmeyer", | ||
| "dependencies": { | ||
| "lodash": "3.10.x", | ||
| "lodash": "4.17.10", | ||
| "map-stream": "0.1.x", | ||
@@ -19,5 +19,7 @@ "preprocess": "^3.0.0" | ||
| "devDependencies": { | ||
| "gulp-util": "3.0.x", | ||
| "eslint": "5.0.1", | ||
| "mocha": "*", | ||
| "should": "*" | ||
| "prettier": "1.13.7", | ||
| "should": "*", | ||
| "vinyl": "2.2.0" | ||
| }, | ||
@@ -31,3 +33,3 @@ "engines": { | ||
| "bugs": { | ||
| "url": "https://github.com/jas/gulp-preprocess/issues" | ||
| "url": "https://github.com/pioug/gulp-preprocess/issues" | ||
| }, | ||
@@ -34,0 +36,0 @@ "directories": { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| # gulp-preprocess [](https://travis-ci.org/jas/gulp-preprocess) [](http://badge.fury.io/js/gulp-preprocess) | ||
| # gulp-preprocess [](https://travis-ci.org/pioug/gulp-preprocess) [](http://badge.fury.io/js/gulp-preprocess) | ||
@@ -3,0 +3,0 @@ > [Gulp](http://gulpjs.com) plugin to preprocess HTML, JavaScript, and other files based on custom context or environment configuration |
+62
-58
@@ -1,140 +0,144 @@ | ||
| var should = require('should'); | ||
| var gutil = require('gulp-util'); | ||
| var preprocess = require('../'); | ||
| var fs = require('fs'); | ||
| var should = require("should"); | ||
| var File = require("vinyl"); | ||
| var preprocess = require("../"); | ||
| var fs = require("fs"); | ||
| require('mocha'); | ||
| require("mocha"); | ||
| function fixtureFile(fileName) { | ||
| return new gutil.File({ | ||
| base: 'test/fixtures', | ||
| cwd: 'test/', | ||
| path: 'test/fixtures/' + fileName, | ||
| contents: fs.readFileSync('test/fixtures/' + fileName) | ||
| return new File({ | ||
| base: "test/fixtures", | ||
| cwd: "test/", | ||
| path: "test/fixtures/" + fileName, | ||
| contents: fs.readFileSync("test/fixtures/" + fileName) | ||
| }); | ||
| }; | ||
| } | ||
| process.env['FAKEHOME'] = '/Users/jas'; | ||
| process.env["FAKEHOME"] = "/Users/jas"; | ||
| describe('gulp-preprocess', function(){ | ||
| describe('preprocess()', function(){ | ||
| it('should preprocess html', function(done){ | ||
| describe("gulp-preprocess", function() { | ||
| describe("preprocess()", function() { | ||
| it("should preprocess html", function(done) { | ||
| var stream = preprocess({ | ||
| context: { | ||
| firstOption: 'bar', | ||
| secondOption: 'foo' | ||
| firstOption: "bar", | ||
| secondOption: "foo" | ||
| } | ||
| }); | ||
| var fakeFile = fixtureFile('test.html'); | ||
| var fakeFile = fixtureFile("test.html"); | ||
| stream.once('data', function(newFile){ | ||
| stream.once("data", function(newFile) { | ||
| should.exist(newFile); | ||
| should.exist(newFile.contents); | ||
| String(newFile.contents).should.equal(fs.readFileSync('test/expected/test.html', 'utf8')); | ||
| String(newFile.contents).should.equal( | ||
| fs.readFileSync("test/expected/test.html", "utf8") | ||
| ); | ||
| done(); | ||
| }); | ||
| stream.write(fakeFile); | ||
| }); | ||
| it('should preprocess javascript', function(done){ | ||
| it("should preprocess javascript", function(done) { | ||
| var stream = preprocess({ | ||
| context: { | ||
| firstOption: 'bar', | ||
| secondOption: 'foo' | ||
| firstOption: "bar", | ||
| secondOption: "foo" | ||
| } | ||
| }); | ||
| var fakeFile = fixtureFile('test.js'); | ||
| var fakeFile = fixtureFile("test.js"); | ||
| stream.once('data', function(newFile){ | ||
| stream.once("data", function(newFile) { | ||
| should.exist(newFile); | ||
| should.exist(newFile.contents); | ||
| String(newFile.contents).should.equal(fs.readFileSync('test/expected/test.js', 'utf8')); | ||
| String(newFile.contents).should.equal( | ||
| fs.readFileSync("test/expected/test.js", "utf8") | ||
| ); | ||
| done(); | ||
| }); | ||
| stream.write(fakeFile); | ||
| }); | ||
| it('should preprocess coffeescript', function(done){ | ||
| it("should preprocess coffeescript", function(done) { | ||
| var stream = preprocess({ | ||
| context: { | ||
| firstOption: 'bar', | ||
| secondOption: 'foo' | ||
| firstOption: "bar", | ||
| secondOption: "foo" | ||
| } | ||
| }); | ||
| var fakeFile = fixtureFile('test.coffee'); | ||
| var fakeFile = fixtureFile("test.coffee"); | ||
| stream.once('data', function(newFile){ | ||
| stream.once("data", function(newFile) { | ||
| should.exist(newFile); | ||
| should.exist(newFile.contents); | ||
| String(newFile.contents).should.equal(fs.readFileSync('test/expected/test.coffee', 'utf8')); | ||
| String(newFile.contents).should.equal( | ||
| fs.readFileSync("test/expected/test.coffee", "utf8") | ||
| ); | ||
| done(); | ||
| }); | ||
| stream.write(fakeFile); | ||
| }); | ||
| it('should preprocess without options object', function(done){ | ||
| it("should preprocess without options object", function(done) { | ||
| var stream = preprocess(); | ||
| var fakeFile = fixtureFile('test.coffee'); | ||
| var fakeFile = fixtureFile("test.coffee"); | ||
| stream.once('data', function(newFile){ | ||
| stream.once("data", function(newFile) { | ||
| should.exist(newFile); | ||
| should.exist(newFile.contents); | ||
| String(newFile.contents).should.equal(fs.readFileSync('test/expected/test.coffee', 'utf8')); | ||
| String(newFile.contents).should.equal( | ||
| fs.readFileSync("test/expected/test.coffee", "utf8") | ||
| ); | ||
| done(); | ||
| }); | ||
| stream.write(fakeFile); | ||
| }); | ||
| it('should preprocess html with custom base', function(done){ | ||
| it("should preprocess html with custom base", function(done) { | ||
| var stream = preprocess({ | ||
| includeBase: 'test/fixtures/base', | ||
| includeBase: "test/fixtures/base", | ||
| context: { | ||
| firstOption: 'bar', | ||
| secondOption: 'foo' | ||
| firstOption: "bar", | ||
| secondOption: "foo" | ||
| } | ||
| }); | ||
| var fakeFile = fixtureFile('test.html'); | ||
| var fakeFile = fixtureFile("test.html"); | ||
| stream.once('data', function(newFile){ | ||
| stream.once("data", function(newFile) { | ||
| should.exist(newFile); | ||
| should.exist(newFile.contents); | ||
| String(newFile.contents).should.equal(fs.readFileSync('test/expected/test-base.html', 'utf8')); | ||
| String(newFile.contents).should.equal( | ||
| fs.readFileSync("test/expected/test-base.html", "utf8") | ||
| ); | ||
| done(); | ||
| }); | ||
| stream.write(fakeFile); | ||
| }); | ||
| it('should allow custom extension', function(done){ | ||
| it("should allow custom extension", function(done) { | ||
| var stream = preprocess({ | ||
| extension: 'html', | ||
| extension: "html", | ||
| context: { | ||
| firstOption: 'bar', | ||
| secondOption: 'foo' | ||
| firstOption: "bar", | ||
| secondOption: "foo" | ||
| } | ||
| }); | ||
| var fakeFile = fixtureFile('test.php'); | ||
| var fakeFile = fixtureFile("test.php"); | ||
| stream.once('data', function(newFile){ | ||
| stream.once("data", function(newFile) { | ||
| should.exist(newFile); | ||
| should.exist(newFile.contents); | ||
| String(newFile.contents).should.equal(fs.readFileSync('test/expected/test.html', 'utf8')); | ||
| String(newFile.contents).should.equal( | ||
| fs.readFileSync("test/expected/test.html", "utf8") | ||
| ); | ||
| done(); | ||
| }); | ||
| stream.write(fakeFile); | ||
| }); | ||
| }); | ||
| }); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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 website
QualityPackage does not have a website.
Found 1 instance in 1 package
12666
2%172
9.55%0
-100%0
-100%5
66.67%+ Added
- Removed
Updated