diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/gulp-gzip/index.js | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) |
remove node_modules
Diffstat (limited to 'node_modules/gulp-gzip/index.js')
-rwxr-xr-x | node_modules/gulp-gzip/index.js | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/node_modules/gulp-gzip/index.js b/node_modules/gulp-gzip/index.js deleted file mode 100755 index b79415f53..000000000 --- a/node_modules/gulp-gzip/index.js +++ /dev/null @@ -1,105 +0,0 @@ -/*jslint node: true */ -'use strict'; - -var fs = require('fs'); -var path = require('path'); -var through2 = require('through2'); -var PluginError = require('plugin-error'); -var fancyLog = require('fancy-log'); -var colors = require('ansi-colors'); -var utils = require('./lib/utils'); -var compress = require('./lib/compress.js'); - -var PLUGIN_NAME = 'gulp-gzip'; - -module.exports = function (options) { - - // Combine user defined options with default options - var defaultConfig = { - append: true, - threshold: false, - gzipOptions: {}, - skipGrowingFiles: false - }; - var config = utils.merge(defaultConfig, options); - - // Create a through2 object stream. This is our plugin export - var stream = through2.obj(gulpGzip); - - // Expose the config so we can test it - stream.config = config; - - function gulpGzip(file, enc, done) { - - /*jshint validthis: true */ - var self = this; - - // Check for empty file - if (file.isNull()) { - // Pass along the empty file to the next plugin - self.push(file); - done(); - return; - } - - // Call when finished with compression - var finished = function(err, contents, wasCompressed) { - if (err) { - var error = new PluginError(PLUGIN_NAME, err, { showStack: true }); - self.emit('error', error); - done(); - return; - } - - var complete = function() { - file.contents = contents; - self.push(file); - done(); - }; - - var getFixedPath = function(filepath) { - if (config.extension) { - filepath += '.' + config.extension; - } else if (config.preExtension) { - filepath = filepath.replace(/(\.[^\.]+)$/, '.' + config.preExtension + '$1'); - } else if (config.append) { - filepath += '.gz'; - } - - return filepath; - }; - - if (wasCompressed) { - if (file.contentEncoding) { - file.contentEncoding.push('gzip'); - } else { - file.contentEncoding = [ 'gzip' ]; - } - - file.path = getFixedPath(file.path); - complete(); - } else if (config.deleteMode) { - var cwd = path.resolve(config.deleteModeCwd || process.cwd()); - var directory = typeof config.deleteMode === 'string' ? config.deleteMode : config.deleteMode(file); - var filepath = path.resolve(cwd, directory, getFixedPath(file.relative)); - - fs.exists(filepath, function(exists) { - if(exists) { - fancyLog(colors.green('Gzipped file ' + filepath + ' deleted')); - fs.unlink(filepath, complete); - } else { - complete(); - } - }); - } else { - complete(); - } - - return; - }; - - compress(file.contents, config, finished); - } - - return stream; -}; |