Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Map vinyl files' contents as strings, so you can easily use existing code without needing yet another gulp plugin!
Map vinyl files' contents as strings, so you can easily use existing code without needing yet another gulp plugin!
Essentially, with the hope of reducing the number of gulp plugins out there which are just doing this:
var through = require('through')
var uglify = require('uglify-js')
module.exports = function() {
return through(function(file) {
if (file.isNull()) return this.queue(file)
if (file.isStream()) throw new Error('no support')
file.contents = file.contents.toString()
var minified = uglify.minify(file.contents, {
fromString: true
})
file = file.clone()
file.contents = new Buffer(minified.code)
this.queue(file)
})
}
Of course, sometimes that's fine too, but this might help save some complexity
for when it's too much hassle. It also takes care of the differences between
handling Buffer, Stream and null values for your file.contents
.
Here's a simple example, using gulp:
var uglify = require('uglify-js')
var map = require('vinyl-map')
var gulp = require('gulp')
gulp.task('minify', function() {
var minify = map(function(code, filename) {
// file contents are handed
// over as buffers
code = code.toString()
return uglify.minify(code, {
fromString: true
}).code
})
return gulp.src(['./index.js'])
.pipe(minify)
.pipe(gulp.dest('./dist'))
})
map(mapper(contents, filename))
Returns a transform stream that takes vinyl files as input and spits out their modified copies as output.
mapper
is a function which will be called once for each file, with two
arguments:
contents
is a string or Bufferfilename
is the value of file.path
, which should generally be the file's
absolute path. Might be convenient if you want to filter based on file
extension etc.The mapper
function is expected to return a modified string value for the
updated file contents. If nothing is returned, no modifications will be made
to the file contents, but the output file will be cloned.
MIT. See LICENSE.md for details.
FAQs
Map vinyl files' contents as strings, so you can easily use existing code without needing yet another gulp plugin!
The npm package vinyl-map receives a total of 11,392 weekly downloads. As such, vinyl-map popularity was classified as popular.
We found that vinyl-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.