first commit

This commit is contained in:
armansansd
2023-07-12 16:31:19 +01:00
commit 3424b1927b
23306 changed files with 2217776 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
## The MIT License (MIT) ##
Copyright (c) 2014 Hugh Kennedy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+75
View File
@@ -0,0 +1,75 @@
# vinyl-source-stream [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/vinyl-source-stream&title=vinyl-source-stream&description=hughsk/vinyl-source-stream%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #
Use conventional text streams at the start of your
[gulp](http://github.com/gulpjs/gulp) or
[vinyl](http://github.com/wearefractal/vinyl) pipelines, making for nicer
interoperability with the existing npm stream ecosystem.
Take, for example, [browserify](http://browserify.org/). There are the
[gulp-browserify](https://github.com/deepak1556/gulp-browserify) and
[gulpify](https://github.com/hughsk/gulpify) plugins, which you can use in
combination with gulp to get browserify working in your build. Unfortunately,
these plugins come with additional overhead: an extra GitHub repository, npm
module, maintainer, tests, semantics, etc. It's much simpler
in this case to use the original module directly where you can, which is what
`vinyl-source-stream` handles for you.
## Usage ##
[![vinyl-source-stream](https://nodei.co/npm/vinyl-source-stream.png?mini=true)](https://nodei.co/npm/vinyl-source-stream)
Our previous example, browserify, has a streaming API for its output bundles
which you can use directly. This module is just a bridge that makes it
simple to use conventional text streams such as this in combination with gulp.
Here's an example of using `vinyl-source-stream` and `browserify`, compared to
using `gulpify`:
``` javascript
var source = require('vinyl-source-stream')
var streamify = require('gulp-streamify')
var browserify = require('browserify')
var uglify = require('gulp-uglify')
var gulpify = require('gulpify')
var rename = require('gulp-rename')
var gulp = require('gulp')
// using gulpify:
gulp.task('gulpify', function() {
gulp.src('index.js')
.pipe(gulpify())
.pipe(uglify())
.pipe(rename('bundle.js'))
.pipe(gulp.dest('./'))
})
// using vinyl-source-stream:
gulp.task('browserify', function() {
var bundleStream = browserify('./index.js').bundle()
bundleStream
.pipe(source('index.js'))
.pipe(streamify(uglify()))
.pipe(rename('bundle.js'))
.pipe(gulp.dest('./'))
})
```
Not all that different, really! The nice thing here is that you're getting the
up-to-date browserify API and don't have to worry about the plugin's available
functionality. Of course, these same benefits apply for any readable text
stream you can find on npm.
## API ##
### `stream = sourceStream([filename])` ###
Creates a through stream which takes text as input, and emits a single
vinyl file instance for streams down the pipeline to consume.
`filename` is a "pretend" filename to use for your file, which some streams
might use to determine various factors such as the final filename of your file.
It should be a string, and though recommended, using this argument is optional.
## License ##
MIT. See [LICENSE.md](http://github.com/hughsk/vinyl-source-stream/blob/master/LICENSE.md) for details.
+32
View File
@@ -0,0 +1,32 @@
var through2 = require('through2')
var File = require('vinyl')
var path = require('path')
module.exports = function (filename, baseDir) {
var ins = through2()
var out = false
var opts = {
contents: ins
}
if (filename) opts.path = path.resolve(baseDir || process.cwd(), filename)
if (baseDir) opts.base = baseDir
var file = new File(opts)
return through2({
objectMode: true
}, function(chunk, enc, next) {
if (!out) {
this.push(file)
out = true
}
ins.push(chunk)
next()
}, function() {
ins.push(null)
this.push(null)
})
}
+69
View File
@@ -0,0 +1,69 @@
{
"_from": "vinyl-source-stream",
"_id": "vinyl-source-stream@2.0.0",
"_inBundle": false,
"_integrity": "sha1-84pa+53R6Ttl1VBGmsYYKsT1S44=",
"_location": "/vinyl-source-stream",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "vinyl-source-stream",
"name": "vinyl-source-stream",
"escapedName": "vinyl-source-stream",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#DEV:/",
"#USER"
],
"_resolved": "https://registry.npmjs.org/vinyl-source-stream/-/vinyl-source-stream-2.0.0.tgz",
"_shasum": "f38a5afb9dd1e93b65d550469ac6182ac4f54b8e",
"_spec": "vinyl-source-stream",
"_where": "/srv/http/mmap_sarrebourg/user/themes/basic",
"author": {
"name": "Hugh Kennedy",
"email": "hughskennedy@gmail.com",
"url": "http://hughsk.io/"
},
"browser": "index.js",
"bugs": {
"url": "https://github.com/hughsk/vinyl-source-stream/issues"
},
"bundleDependencies": false,
"dependencies": {
"through2": "^2.0.3",
"vinyl": "^2.1.0"
},
"deprecated": false,
"description": "Use conventional text streams at the start of your gulp or vinyl pipelines",
"devDependencies": {
"gulp-rename": "~0.2.1",
"tape": "~2.3.2",
"vinyl-fs": "^3.0.0"
},
"homepage": "https://github.com/hughsk/vinyl-source-stream",
"keywords": [
"vinyl",
"gulp",
"gulpfriendly",
"vanilla",
"stream",
"string",
"text",
"classic"
],
"license": "MIT",
"main": "index.js",
"name": "vinyl-source-stream",
"repository": {
"type": "git",
"url": "git://github.com/hughsk/vinyl-source-stream.git"
},
"scripts": {
"test": "node test"
},
"version": "2.0.0"
}
+56
View File
@@ -0,0 +1,56 @@
var rename = require('gulp-rename')
var srcStream = require('./')
var vfs = require('vinyl-fs')
var test = require('tape')
var path = require('path')
var fs = require('fs')
var through = require('through2');
function upper() {
return through(function(chunk, _, cb) {
var str = chunk.toString().toUpperCase();
cb(null, new Buffer(str));
});
}
test('capitalizing test file', function(t) {
fs.createReadStream(__filename)
.pipe(srcStream(__filename))
.pipe(through.obj(function(file, _, cb) {
file.contents = file.contents.pipe(upper());
cb(null, file);
}))
.pipe(rename("fixture.js"))
.pipe(vfs.dest('.'))
.once('end', function() {
// gulp.dest finishes before writing
// the file is complete...
setTimeout(function() {
t.pass('reached pipline "end" event')
t.equal(
fs.readFileSync(__dirname + '/fixture.js', 'utf8')
, fs.readFileSync(__filename, 'utf8').toUpperCase()
, 'transformed contents as expected'
)
fs.unlink(__dirname + '/fixture.js', function(err) {
t.ifError(err, 'removed fixture successfully')
t.end()
})
}, 1500)
})
})
test('baseDir: defaults to process.cwd()', function(t) {
process.chdir(path.resolve(__dirname, '..', '..'))
fs.createReadStream(__filename)
.pipe(srcStream(path.basename(__filename)))
.on('data', function(file) {
t.equal(process.cwd(), path.dirname(file.path), 'defaults to process.cwd()')
process.chdir(__dirname)
t.end()
})
})