gulp-preprocess-file
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -23,8 +23,4 @@ module.exports = { | ||
"single" | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
] | ||
} | ||
}; |
@@ -1,47 +0,47 @@ | ||
const through = require('through2'); | ||
const through = require('through2') | ||
const path = require('path') | ||
const gutil = require('gulp-util'); | ||
const PluginError = gutil.PluginError; | ||
const PluginError = require('plugin-error') | ||
const _ = require('lodash') | ||
const pp = require('preprocess'); | ||
const pp = require('preprocess') | ||
const PLUGIN_NAME = 'gulp-preprocess-file'; | ||
const PLUGIN_NAME = 'gulp-preprocess-file' | ||
function gulpPreprocessFile(context, options) { | ||
context = _.merge({ | ||
NODE_ENV: 'development' | ||
}, process.env, context) | ||
context = _.merge({ | ||
NODE_ENV: 'development' | ||
// eslint-disable-next-line no-undef | ||
}, process.env, context) | ||
// create stream | ||
// function(file, encoding, callback) | ||
var stream = through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
this.push(file) | ||
return cb(); | ||
} | ||
// create stream | ||
// function(file, encoding, callback) | ||
var stream = through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
this.push(file) | ||
return cb() | ||
} | ||
if (file.isStream()) { | ||
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!')); | ||
return cb(); | ||
} | ||
if (file.isStream()) { | ||
this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!')) | ||
return cb() | ||
} | ||
context.srcDir = context.srcDir || path.dirname(file.path) | ||
options = _.isEmpty(options) ? getFileType(file.path) : options | ||
context.srcDir = context.srcDir || path.dirname(file.path) | ||
options = _.isEmpty(options) ? getFileType(file.path) : options | ||
if (file.isBuffer()) { | ||
var content = pp.preprocess(file.contents.toString(), context, options) | ||
file.contents = new Buffer(content) | ||
} | ||
if (file.isBuffer()) { | ||
var content = pp.preprocess(file.contents.toString(), context, options) | ||
file.contents = new Buffer(content) | ||
} | ||
this.push(file); | ||
cb(); | ||
}); | ||
this.push(file) | ||
cb() | ||
}) | ||
return stream; | ||
}; | ||
return stream | ||
} | ||
function getFileType(file) { | ||
return path.extname(file).split('.').pop() || '' | ||
return path.extname(file).split('.').pop() || '' | ||
} | ||
module.exports = gulpPreprocessFile; | ||
module.exports = gulpPreprocessFile |
{ | ||
"name": "gulp-preprocess-file", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "A Gulp plugin for Preprocess files based off environment configuration. Based on Preprocess package", | ||
@@ -26,6 +26,5 @@ "main": "lib/index.js", | ||
"homepage": "https://github.com/mengqing723/gulp-preprocess-file#readme", | ||
"devDependencies": {}, | ||
"dependencies": { | ||
"gulp-util": "^3.0.8", | ||
"lodash": "^4.17.10", | ||
"plugin-error": "^1.0.1", | ||
"preprocess": "^3.1.0", | ||
@@ -32,0 +31,0 @@ "through2": "^2.0.3" |
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
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
4608
4
61
+ Addedplugin-error@^1.0.1
+ Addedansi-colors@1.1.0(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedextend-shallow@3.0.2(transitive)
+ Addedis-extendable@1.0.1(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedisobject@3.0.1(transitive)
+ Addedplugin-error@1.0.1(transitive)
- Removedgulp-util@^3.0.8
- Removedansi-gray@0.1.1(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedarray-differ@1.0.0(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedbeeper@1.1.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedclone@1.0.4(transitive)
- Removedclone-stats@0.0.1(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removeddateformat@2.2.0(transitive)
- Removedduplexer2@0.0.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfancy-log@1.3.3(transitive)
- Removedglogg@1.0.2(transitive)
- Removedgulp-util@3.0.8(transitive)
- Removedgulplog@1.0.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-gulplog@0.1.0(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash._basecopy@3.0.1(transitive)
- Removedlodash._basetostring@3.0.1(transitive)
- Removedlodash._basevalues@3.0.0(transitive)
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash._isiterateecall@3.0.9(transitive)
- Removedlodash._reescape@3.0.0(transitive)
- Removedlodash._reevaluate@3.0.0(transitive)
- Removedlodash._reinterpolate@3.0.0(transitive)
- Removedlodash._root@3.0.1(transitive)
- Removedlodash.escape@3.2.0(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.keys@3.1.2(transitive)
- Removedlodash.restparam@3.6.1(transitive)
- Removedlodash.template@3.6.2(transitive)
- Removedlodash.templatesettings@3.1.1(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmultipipe@0.1.2(transitive)
- Removedobject-assign@3.0.0(transitive)
- Removedparse-node-version@1.0.1(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedreplace-ext@0.0.1(transitive)
- Removedsparkles@1.0.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedtime-stamp@1.1.0(transitive)
- Removedvinyl@0.5.3(transitive)