New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-preprocess

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-preprocess - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

.eslintrc

27

index.js

@@ -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];
}
{
"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,2 +0,2 @@

# gulp-preprocess [![Build Status](https://travis-ci.org/jas/gulp-preprocess.png?branch=master)](https://travis-ci.org/jas/gulp-preprocess) [![NPM version](https://badge.fury.io/js/gulp-preprocess.png)](http://badge.fury.io/js/gulp-preprocess)
# gulp-preprocess [![Build Status](https://travis-ci.org/pioug/gulp-preprocess.png?branch=master)](https://travis-ci.org/pioug/gulp-preprocess) [![NPM version](https://badge.fury.io/js/gulp-preprocess.png)](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

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc