Migration datamodels !
This commit is contained in:
15
node_modules/gulp-sourcemaps/LICENSE.md
generated
vendored
Normal file
15
node_modules/gulp-sourcemaps/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
## ISC License
|
||||
|
||||
Copyright (c) 2014, Florian Reiterer
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
444
node_modules/gulp-sourcemaps/README.md
generated
vendored
Normal file
444
node_modules/gulp-sourcemaps/README.md
generated
vendored
Normal file
@@ -0,0 +1,444 @@
|
||||
# gulp-sourcemaps
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url]
|
||||
|
||||
Sourcemap support for gulpjs.
|
||||
|
||||
### Usage
|
||||
|
||||
All the examples here works with Gulp 4. To see examples related to Gulp 3, [you can read them here](https://github.com/gulp-sourcemaps/gulp-sourcemaps/blob/v2.6.5/README.md).
|
||||
|
||||
#### Write inline source maps
|
||||
Inline source maps are embedded in the source file.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var plugin1 = require('gulp-plugin1');
|
||||
var plugin2 = require('gulp-plugin2');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
||||
function javascript() {
|
||||
gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
All plugins between `sourcemaps.init()` and `sourcemaps.write()` need to have support for `gulp-sourcemaps`. You can find a list of such plugins in the [wiki](https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support).
|
||||
|
||||
|
||||
#### Write external source map files
|
||||
|
||||
To write external source map files, pass a path relative to the destination to `sourcemaps.write()`.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var plugin1 = require('gulp-plugin1');
|
||||
var plugin2 = require('gulp-plugin2');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
||||
function javascript() {
|
||||
gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps'))
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
#### Load existing source maps
|
||||
|
||||
To load existing source maps, pass the option `loadMaps: true` to `sourcemaps.init()`.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var plugin1 = require('gulp-plugin1');
|
||||
var plugin2 = require('gulp-plugin2');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
||||
function javascript() {
|
||||
gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init({loadMaps: true}))
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
#### Handle large files
|
||||
|
||||
To handle large files, pass the option `largeFile: true` to `sourcemaps.init()`.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var plugin1 = require('gulp-plugin1');
|
||||
var plugin2 = require('gulp-plugin2');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
||||
function javascript() {
|
||||
gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init({largeFile: true}))
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
#### Handle source files from different directories
|
||||
|
||||
Use the `base` option on `gulp.src` to make sure all files are relative to a common base directory.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
var gulp = require('gulp');
|
||||
var plugin1 = require('gulp-plugin1');
|
||||
var plugin2 = require('gulp-plugin2');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
|
||||
function javascript() {
|
||||
gulp.src(['src/test.js', 'src/testdir/test2.js'], { base: 'src' })
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps'))
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
#### Alter `sources` property on sourcemaps
|
||||
|
||||
The exported `mapSources` method gives full control over the source paths. It takes a function that is called for every source and receives the default source path as a parameter and the original vinyl file.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
// be careful with the sources returned otherwise contents might not be loaded properly
|
||||
.pipe(sourcemaps.mapSources(function(sourcePath, file) {
|
||||
// source paths are prefixed with '../src/'
|
||||
return '../src/' + sourcePath;
|
||||
}))
|
||||
.pipe(sourcemaps.write('../maps')
|
||||
.pipe(gulp.dest('public/scripts'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
#### Generate Identity Sourcemap
|
||||
|
||||
The exported `identityMap` method allows you to generate a full valid source map encoding no changes (slower, only for Javascript and CSS) instead of the default empty source map (no mappings, fast). __Use this option if you get missing or incorrect mappings, e.g. when debugging.__
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
// An identity sourcemap will be generated at this step
|
||||
.pipe(sourcemaps.identityMap())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps')
|
||||
.pipe(gulp.dest('public/scripts'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
|
||||
### Init Options
|
||||
|
||||
- `loadMaps`
|
||||
|
||||
Set to true to load existing maps for source files. Supports the following:
|
||||
- inline source maps
|
||||
- source map files referenced by a `sourceMappingURL=` comment
|
||||
- source map files with the same name (plus .map) in the same directory
|
||||
|
||||
|
||||
- `identityMap`
|
||||
|
||||
__This option is deprecated. Upgrade to use our [`sourcemap.identityMap`](#generate-identity-sourcemap) API.__
|
||||
|
||||
|
||||
### Write Options
|
||||
|
||||
- `addComment`
|
||||
|
||||
By default a comment containing / referencing the source map is added. Set this to `false` to disable the comment (e.g. if you want to load the source maps by header).
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps', {addComment: false}))
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
- `includeContent`
|
||||
|
||||
By default the source maps include the source code. Pass `false` to use the original files.
|
||||
|
||||
Including the content is the recommended way, because it "just works". When setting this to `false` you have to host the source files and set the correct `sourceRoot`.
|
||||
|
||||
- `sourceRoot`
|
||||
|
||||
Set the location where the source files are hosted (use this when `includeContent` is set to `false`). This is usually a URL (or an absolute URL path), not a local file system path.
|
||||
By default the source root is '' or in case `destPath` is set, the relative path from the source map to the source base directory (this should work for many dev environments).
|
||||
If a relative path is used (empty string or one starting with a `.`), it is interpreted as a path relative to the destination. The plugin rewrites it to a path relative to each source map.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write({includeContent: false, sourceRoot: '/src'}))
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
Example (using a function):
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write({
|
||||
includeContent: false,
|
||||
sourceRoot: function(file) {
|
||||
return '/src';
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
Example (relative path):
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '../src'}))
|
||||
.pipe(gulp.dest('dist'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
In this case for a file written to `dist/subdir/example.js`, the source map is written to `dist/subdir/example.js.map` and the sourceRoot will be `../../src` (resulting in the full source path `../../src/subdir/example.js`).
|
||||
|
||||
- `destPath`
|
||||
|
||||
Set the destination path (the same you pass to `gulp.dest()`). If the source map destination path is not a sub path of the destination path, this is needed to get the correct path in the `file` property of the source map.
|
||||
In addition, it allows to automatically set a relative `sourceRoot` if none is set explicitly.
|
||||
|
||||
- `sourceMappingURLPrefix`
|
||||
|
||||
Specify a prefix to be prepended onto the source map URL when writing external source maps. Relative paths will have their leading dots stripped.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps', {
|
||||
sourceMappingURLPrefix: 'https://asset-host.example.com/assets'
|
||||
}))
|
||||
.pipe(gulp.dest('public/scripts'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
This will result in a source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/assets/maps/helloworld.js.map`.
|
||||
|
||||
- `sourceMappingURL`
|
||||
|
||||
If you need full control over the source map URL you can pass a function to this option. The output of the function must be the full URL to the source map (in function of the output file).
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps', {
|
||||
sourceMappingURL: function(file) {
|
||||
return 'https://asset-host.example.com/' + file.relative + '.map';
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest('public/scripts'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
This will result in a source mapping URL comment like `sourceMappingURL=https://asset-host.example.com/helloworld.js.map`.
|
||||
|
||||
- `mapFile`
|
||||
|
||||
This option allows to rename the map file. It takes a function that is called for every map and receives the default map path as a parameter.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
function javascript() {
|
||||
var stream = gulp.src('src/**/*.js')
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(plugin1())
|
||||
.pipe(plugin2())
|
||||
.pipe(sourcemaps.write('../maps', {
|
||||
mapFile: function(mapFilePath) {
|
||||
// source map files are named *.map instead of *.js.map
|
||||
return mapFilePath.replace('.js.map', '.map');
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest('public/scripts'));
|
||||
};
|
||||
|
||||
exports.javascript = javascript;
|
||||
```
|
||||
|
||||
- `mapSources`
|
||||
|
||||
__This option is deprecated. Upgrade to use our [`sourcemap.mapSources`](#alter-sources-property-on-sourcemaps) API.__
|
||||
|
||||
- `charset`
|
||||
|
||||
Sets the charset for inline source maps. Default: `utf8`
|
||||
|
||||
- `clone`
|
||||
|
||||
Clones the original file for creation of the map file. Could be important if file history is important. See [file.clone()](https://github.com/gulpjs/vinyl#filecloneoptions) for possible options. Default: `{deep:false, contents:false}`
|
||||
|
||||
### Plugin developers only:
|
||||
|
||||
- **How to add source map support to plugins**
|
||||
|
||||
- Generate a source map for the transformation the plugin is applying
|
||||
- **Important**: Make sure the paths in the generated source map (`file` and `sources`) are relative to `file.base` (e.g. use `file.relative`).
|
||||
- Apply this source map to the vinyl `file`. E.g. by using [vinyl-sourcemaps-apply](https://github.com/gulp-sourcemaps/vinyl-sourcemaps-apply).
|
||||
This combines the source map of this plugin with the source maps coming from plugins further up the chain.
|
||||
- Add your plugin to the [wiki page](https://github.com/gulp-sourcemaps/gulp-sourcemaps/wiki/Plugins-with-gulp-sourcemaps-support)
|
||||
|
||||
#### Example:
|
||||
|
||||
```js
|
||||
var through = require('through2');
|
||||
var applySourceMap = require('vinyl-sourcemaps-apply');
|
||||
var myTransform = require('myTransform');
|
||||
|
||||
module.exports = function(options) {
|
||||
|
||||
function transform(file, encoding, callback) {
|
||||
// generate source maps if plugin source-map present
|
||||
if (file.sourceMap) {
|
||||
options.makeSourceMaps = true;
|
||||
}
|
||||
|
||||
// do normal plugin logic
|
||||
var result = myTransform(file.contents, options);
|
||||
file.contents = new Buffer(result.code);
|
||||
|
||||
// apply source map to the chain
|
||||
if (file.sourceMap) {
|
||||
applySourceMap(file, result.map);
|
||||
}
|
||||
|
||||
this.push(file);
|
||||
callback();
|
||||
}
|
||||
|
||||
return through.obj(transform);
|
||||
};
|
||||
```
|
||||
|
||||
- **Verify sourcemaps are working**
|
||||
|
||||
See example below or refer to [test/write.js](./test/write.js)
|
||||
|
||||
#### Example:
|
||||
```js
|
||||
var stream = plugin();
|
||||
var init = sourcemaps.init();
|
||||
var write = sourcemaps.write();
|
||||
|
||||
init.pipe(stream).pipe(write);
|
||||
|
||||
write.on('data', function (file) {
|
||||
assert(...);
|
||||
cb();
|
||||
});
|
||||
|
||||
init.write(new gutil.File(...));
|
||||
init.end();
|
||||
```
|
||||
|
||||
### Debugging
|
||||
|
||||
All debugging output relies on [visionmedia/debug](https://github.com/visionmedia/debug). Follow the directions to set the
|
||||
environment variable `$DEBUG`.
|
||||
|
||||
For a few examples of debug you could use:
|
||||
|
||||
```sh
|
||||
DEBUG='gulp-sourcemaps:*' #everything
|
||||
DEBUG='gulp-sourcemaps:init' #init/index.js
|
||||
DEBUG='gulp-sourcemaps:init:*' #init/index.internals.js
|
||||
DEBUG='gulp-sourcemaps:write:' #write/index.js
|
||||
DEBUG='gulp-sourcemaps:write:*' #write/index.internals.js
|
||||
DEBUG='gulp-sourcemaps:write:,gulp-sourcemaps:init:**' #write/index.internals.js and init/index.internals.js
|
||||
```
|
||||
|
||||
[downloads-image]: http://img.shields.io/npm/dm/gulp-sourcemaps.svg
|
||||
[npm-url]: https://www.npmjs.com/package/gulp-sourcemaps
|
||||
[npm-image]: http://img.shields.io/npm/v/gulp-sourcemaps.svg
|
||||
|
||||
[travis-url]: https://travis-ci.org/gulp-sourcemaps/gulp-sourcemaps
|
||||
[travis-image]: http://img.shields.io/travis/gulp-sourcemaps/gulp-sourcemaps.svg?label=travis-ci
|
||||
|
||||
[appveyor-url]: https://ci.appveyor.com/project/phated/gulp-sourcemaps
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/phated/gulp-sourcemaps.svg?label=appveyor
|
||||
|
||||
[coveralls-url]: https://coveralls.io/r/gulp-sourcemaps/gulp-sourcemaps
|
||||
[coveralls-image]: http://img.shields.io/coveralls/gulp-sourcemaps/gulp-sourcemaps/master.svg
|
||||
8
node_modules/gulp-sourcemaps/index.js
generated
vendored
Normal file
8
node_modules/gulp-sourcemaps/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
init: require('./src/init'),
|
||||
write: require('./src/write'),
|
||||
mapSources: require('@gulp-sourcemaps/map-sources'),
|
||||
identityMap: require('@gulp-sourcemaps/identity-map'),
|
||||
};
|
||||
9
node_modules/gulp-sourcemaps/node_modules/through2/LICENSE.md
generated
vendored
Normal file
9
node_modules/gulp-sourcemaps/node_modules/through2/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
**Copyright (c) Rod Vagg (the "Original Author") and additional contributors**
|
||||
|
||||
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.
|
||||
134
node_modules/gulp-sourcemaps/node_modules/through2/README.md
generated
vendored
Normal file
134
node_modules/gulp-sourcemaps/node_modules/through2/README.md
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
# through2
|
||||
|
||||
[](https://nodei.co/npm/through2/)
|
||||
|
||||
**A tiny wrapper around Node streams.Transform (Streams2/3) to avoid explicit subclassing noise**
|
||||
|
||||
Inspired by [Dominic Tarr](https://github.com/dominictarr)'s [through](https://github.com/dominictarr/through) in that it's so much easier to make a stream out of a function than it is to set up the prototype chain properly: `through(function (chunk) { ... })`.
|
||||
|
||||
Note: As 2.x.x this module starts using **Streams3** instead of Stream2. To continue using a Streams2 version use `npm install through2@0` to fetch the latest version of 0.x.x. More information about Streams2 vs Streams3 and recommendations see the article **[Why I don't use Node's core 'stream' module](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html)**.
|
||||
|
||||
```js
|
||||
fs.createReadStream('ex.txt')
|
||||
.pipe(through2(function (chunk, enc, callback) {
|
||||
for (var i = 0; i < chunk.length; i++)
|
||||
if (chunk[i] == 97)
|
||||
chunk[i] = 122 // swap 'a' for 'z'
|
||||
|
||||
this.push(chunk)
|
||||
|
||||
callback()
|
||||
}))
|
||||
.pipe(fs.createWriteStream('out.txt'))
|
||||
.on('finish', () => doSomethingSpecial())
|
||||
```
|
||||
|
||||
Or object streams:
|
||||
|
||||
```js
|
||||
var all = []
|
||||
|
||||
fs.createReadStream('data.csv')
|
||||
.pipe(csv2())
|
||||
.pipe(through2.obj(function (chunk, enc, callback) {
|
||||
var data = {
|
||||
name : chunk[0]
|
||||
, address : chunk[3]
|
||||
, phone : chunk[10]
|
||||
}
|
||||
this.push(data)
|
||||
|
||||
callback()
|
||||
}))
|
||||
.on('data', (data) => {
|
||||
all.push(data)
|
||||
})
|
||||
.on('end', () => {
|
||||
doSomethingSpecial(all)
|
||||
})
|
||||
```
|
||||
|
||||
Note that `through2.obj(fn)` is a convenience wrapper around `through2({ objectMode: true }, fn)`.
|
||||
|
||||
## API
|
||||
|
||||
<b><code>through2([ options, ] [ transformFunction ] [, flushFunction ])</code></b>
|
||||
|
||||
Consult the **[stream.Transform](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_transform)** documentation for the exact rules of the `transformFunction` (i.e. `this._transform`) and the optional `flushFunction` (i.e. `this._flush`).
|
||||
|
||||
### options
|
||||
|
||||
The options argument is optional and is passed straight through to `stream.Transform`. So you can use `objectMode:true` if you are processing non-binary streams (or just use `through2.obj()`).
|
||||
|
||||
The `options` argument is first, unlike standard convention, because if I'm passing in an anonymous function then I'd prefer for the options argument to not get lost at the end of the call:
|
||||
|
||||
```js
|
||||
fs.createReadStream('/tmp/important.dat')
|
||||
.pipe(through2({ objectMode: true, allowHalfOpen: false },
|
||||
(chunk, enc, cb) => {
|
||||
cb(null, 'wut?') // note we can use the second argument on the callback
|
||||
// to provide data as an alternative to this.push('wut?')
|
||||
}
|
||||
)
|
||||
.pipe(fs.createWriteStream('/tmp/wut.txt'))
|
||||
```
|
||||
|
||||
### transformFunction
|
||||
|
||||
The `transformFunction` must have the following signature: `function (chunk, encoding, callback) {}`. A minimal implementation should call the `callback` function to indicate that the transformation is done, even if that transformation means discarding the chunk.
|
||||
|
||||
To queue a new chunk, call `this.push(chunk)`—this can be called as many times as required before the `callback()` if you have multiple pieces to send on.
|
||||
|
||||
Alternatively, you may use `callback(err, chunk)` as shorthand for emitting a single chunk or an error.
|
||||
|
||||
If you **do not provide a `transformFunction`** then you will get a simple pass-through stream.
|
||||
|
||||
### flushFunction
|
||||
|
||||
The optional `flushFunction` is provided as the last argument (2nd or 3rd, depending on whether you've supplied options) is called just prior to the stream ending. Can be used to finish up any processing that may be in progress.
|
||||
|
||||
```js
|
||||
fs.createReadStream('/tmp/important.dat')
|
||||
.pipe(through2(
|
||||
(chunk, enc, cb) => cb(null, chunk), // transform is a noop
|
||||
function (cb) { // flush function
|
||||
this.push('tacking on an extra buffer to the end');
|
||||
cb();
|
||||
}
|
||||
))
|
||||
.pipe(fs.createWriteStream('/tmp/wut.txt'));
|
||||
```
|
||||
|
||||
<b><code>through2.ctor([ options, ] transformFunction[, flushFunction ])</code></b>
|
||||
|
||||
Instead of returning a `stream.Transform` instance, `through2.ctor()` returns a **constructor** for a custom Transform. This is useful when you want to use the same transform logic in multiple instances.
|
||||
|
||||
```js
|
||||
var FToC = through2.ctor({objectMode: true}, function (record, encoding, callback) {
|
||||
if (record.temp != null && record.unit == "F") {
|
||||
record.temp = ( ( record.temp - 32 ) * 5 ) / 9
|
||||
record.unit = "C"
|
||||
}
|
||||
this.push(record)
|
||||
callback()
|
||||
})
|
||||
|
||||
// Create instances of FToC like so:
|
||||
var converter = new FToC()
|
||||
// Or:
|
||||
var converter = FToC()
|
||||
// Or specify/override options when you instantiate, if you prefer:
|
||||
var converter = FToC({objectMode: true})
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [through2-map](https://github.com/brycebaril/through2-map) - Array.prototype.map analog for streams.
|
||||
- [through2-filter](https://github.com/brycebaril/through2-filter) - Array.prototype.filter analog for streams.
|
||||
- [through2-reduce](https://github.com/brycebaril/through2-reduce) - Array.prototype.reduce analog for streams.
|
||||
- [through2-spy](https://github.com/brycebaril/through2-spy) - Wrapper for simple stream.PassThrough spies.
|
||||
- the [mississippi stream utility collection](https://github.com/maxogden/mississippi) includes `through2` as well as many more useful stream modules similar to this one
|
||||
|
||||
## License
|
||||
|
||||
**through2** is Copyright (c) Rod Vagg [@rvagg](https://twitter.com/rvagg) and additional contributors and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
|
||||
33
node_modules/gulp-sourcemaps/node_modules/through2/package.json
generated
vendored
Normal file
33
node_modules/gulp-sourcemaps/node_modules/through2/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "through2",
|
||||
"version": "2.0.5",
|
||||
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
|
||||
"main": "through2.js",
|
||||
"scripts": {
|
||||
"test": "node test/test.js | faucet"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rvagg/through2.git"
|
||||
},
|
||||
"keywords": [
|
||||
"stream",
|
||||
"streams2",
|
||||
"through",
|
||||
"transform"
|
||||
],
|
||||
"author": "Rod Vagg <r@va.gg> (https://github.com/rvagg)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"readable-stream": "~2.3.6",
|
||||
"xtend": "~4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bl": "~2.0.1",
|
||||
"faucet": "0.0.1",
|
||||
"nyc": "~13.1.0",
|
||||
"safe-buffer": "~5.1.2",
|
||||
"stream-spigot": "~3.0.6",
|
||||
"tape": "~4.9.1"
|
||||
}
|
||||
}
|
||||
96
node_modules/gulp-sourcemaps/node_modules/through2/through2.js
generated
vendored
Normal file
96
node_modules/gulp-sourcemaps/node_modules/through2/through2.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
var Transform = require('readable-stream').Transform
|
||||
, inherits = require('util').inherits
|
||||
, xtend = require('xtend')
|
||||
|
||||
function DestroyableTransform(opts) {
|
||||
Transform.call(this, opts)
|
||||
this._destroyed = false
|
||||
}
|
||||
|
||||
inherits(DestroyableTransform, Transform)
|
||||
|
||||
DestroyableTransform.prototype.destroy = function(err) {
|
||||
if (this._destroyed) return
|
||||
this._destroyed = true
|
||||
|
||||
var self = this
|
||||
process.nextTick(function() {
|
||||
if (err)
|
||||
self.emit('error', err)
|
||||
self.emit('close')
|
||||
})
|
||||
}
|
||||
|
||||
// a noop _transform function
|
||||
function noop (chunk, enc, callback) {
|
||||
callback(null, chunk)
|
||||
}
|
||||
|
||||
|
||||
// create a new export function, used by both the main export and
|
||||
// the .ctor export, contains common logic for dealing with arguments
|
||||
function through2 (construct) {
|
||||
return function (options, transform, flush) {
|
||||
if (typeof options == 'function') {
|
||||
flush = transform
|
||||
transform = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
if (typeof transform != 'function')
|
||||
transform = noop
|
||||
|
||||
if (typeof flush != 'function')
|
||||
flush = null
|
||||
|
||||
return construct(options, transform, flush)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// main export, just make me a transform stream!
|
||||
module.exports = through2(function (options, transform, flush) {
|
||||
var t2 = new DestroyableTransform(options)
|
||||
|
||||
t2._transform = transform
|
||||
|
||||
if (flush)
|
||||
t2._flush = flush
|
||||
|
||||
return t2
|
||||
})
|
||||
|
||||
|
||||
// make me a reusable prototype that I can `new`, or implicitly `new`
|
||||
// with a constructor call
|
||||
module.exports.ctor = through2(function (options, transform, flush) {
|
||||
function Through2 (override) {
|
||||
if (!(this instanceof Through2))
|
||||
return new Through2(override)
|
||||
|
||||
this.options = xtend(options, override)
|
||||
|
||||
DestroyableTransform.call(this, this.options)
|
||||
}
|
||||
|
||||
inherits(Through2, DestroyableTransform)
|
||||
|
||||
Through2.prototype._transform = transform
|
||||
|
||||
if (flush)
|
||||
Through2.prototype._flush = flush
|
||||
|
||||
return Through2
|
||||
})
|
||||
|
||||
|
||||
module.exports.obj = through2(function (options, transform, flush) {
|
||||
var t2 = new DestroyableTransform(xtend({ objectMode: true, highWaterMark: 16 }, options))
|
||||
|
||||
t2._transform = transform
|
||||
|
||||
if (flush)
|
||||
t2._flush = flush
|
||||
|
||||
return t2
|
||||
})
|
||||
62
node_modules/gulp-sourcemaps/package.json
generated
vendored
Normal file
62
node_modules/gulp-sourcemaps/package.json
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "gulp-sourcemaps",
|
||||
"version": "3.0.0",
|
||||
"description": "Sourcemap support for gulpjs.",
|
||||
"homepage": "http://github.com/gulp-sourcemaps/gulp-sourcemaps",
|
||||
"repository": "git://github.com/gulp-sourcemaps/gulp-sourcemaps.git",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"pretest": "npm run lint",
|
||||
"test": "mocha --async-only",
|
||||
"cover": "istanbul cover _mocha --report lcovonly",
|
||||
"coveralls": "npm run cover && istanbul-coveralls"
|
||||
},
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"gulp",
|
||||
"source maps",
|
||||
"sourcemaps"
|
||||
],
|
||||
"author": "Florian Reiterer <me@florianreiterer.com>",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@gulp-sourcemaps/identity-map": "^2.0.1",
|
||||
"@gulp-sourcemaps/map-sources": "^1.0.0",
|
||||
"acorn": "^6.4.1",
|
||||
"convert-source-map": "^1.0.0",
|
||||
"css": "^3.0.0",
|
||||
"debug-fabulous": "^1.0.0",
|
||||
"detect-newline": "^2.0.0",
|
||||
"graceful-fs": "^4.0.0",
|
||||
"source-map": "^0.6.0",
|
||||
"strip-bom-string": "^1.0.0",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bootstrap": "^3.4.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-gulp": "^3.0.1",
|
||||
"expect": "^1.20.2",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-if": "^2.0.2",
|
||||
"gulp-less": "^3.0.0",
|
||||
"gulp-load-plugins": "^1.5.0",
|
||||
"hook-std": "0.2.X",
|
||||
"istanbul": "^0.4.3",
|
||||
"istanbul-coveralls": "^1.0.3",
|
||||
"mississippi": "1.X",
|
||||
"mocha": "^3.5.3",
|
||||
"object-assign": "^4.1.1",
|
||||
"rimraf": "^2.6.3",
|
||||
"vinyl": "^2.2.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"src"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
}
|
||||
1
node_modules/gulp-sourcemaps/src/debug.js
generated
vendored
Normal file
1
node_modules/gulp-sourcemaps/src/debug.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('debug-fabulous').spawnable(require('../package.json').name);
|
||||
131
node_modules/gulp-sourcemaps/src/init/index.internals.js
generated
vendored
Normal file
131
node_modules/gulp-sourcemaps/src/init/index.internals.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('../utils');
|
||||
var rootDebug = require('../debug');
|
||||
var convert = require('convert-source-map');
|
||||
var stripBom = require('strip-bom-string');
|
||||
var urlRegex = utils.urlRegex;
|
||||
var fs = require('graceful-fs');
|
||||
var path = require('path');
|
||||
var unixStylePath = utils.unixStylePath;
|
||||
var exceptionToString = utils.exceptionToString;
|
||||
|
||||
module.exports = function(options, file, fileContent) {
|
||||
|
||||
function loadMaps() {
|
||||
|
||||
var sources = {
|
||||
path: '',
|
||||
map: null,
|
||||
content: fileContent,
|
||||
preExistingComment: null,
|
||||
};
|
||||
|
||||
_getInlineSources(sources);
|
||||
if (!sources.map) {
|
||||
// ahh not inline, so try file
|
||||
_getFileSources(sources);
|
||||
}
|
||||
|
||||
_fixSources(sources);
|
||||
|
||||
return sources;
|
||||
}
|
||||
|
||||
function _fixSources(sources) {
|
||||
var debug = rootDebug.spawn('init:internals:loadMaps:_fixSources');
|
||||
|
||||
// fix source paths and sourceContent for imported source map
|
||||
if (sources.map) {
|
||||
sources.map.sourcesContent = sources.map.sourcesContent || [];
|
||||
sources.map.sources.forEach(function(source, i) {
|
||||
if (source.match(urlRegex)) {
|
||||
sources.map.sourcesContent[i] = sources.map.sourcesContent[i] || null;
|
||||
return;
|
||||
}
|
||||
var absPath = path.resolve(sources.path, source);
|
||||
sources.map.sources[i] = unixStylePath(path.relative(file.base, absPath));
|
||||
|
||||
if (!sources.map.sourcesContent[i]) {
|
||||
var sourceContent = null;
|
||||
if (sources.map.sourceRoot) {
|
||||
if (sources.map.sourceRoot.match(urlRegex)) {
|
||||
sources.map.sourcesContent[i] = null;
|
||||
return;
|
||||
}
|
||||
absPath = path.resolve(sources.path, sources.map.sourceRoot, source);
|
||||
}
|
||||
|
||||
// if current file: use content
|
||||
if (absPath === file.path) {
|
||||
sourceContent = sources.content;
|
||||
} else { // attempt load content from file
|
||||
try {
|
||||
debug(function() { return 'No source content for "' + source + '". Loading from file.'; });
|
||||
sourceContent = stripBom(fs.readFileSync(absPath, 'utf8'));
|
||||
} catch (e) {
|
||||
debug(function() { return 'warn: source file not found: ' + absPath; });
|
||||
}
|
||||
}
|
||||
sources.map.sourcesContent[i] = sourceContent;
|
||||
}
|
||||
|
||||
});
|
||||
// remove source map comment from source
|
||||
file.contents = new Buffer(sources.content, 'utf8');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function _getInlineSources(sources) {
|
||||
var debug = rootDebug.spawn('init:internals:loadMaps:_getInlineSources');
|
||||
|
||||
sources.preExistingComment = utils.getInlinePreExisting(sources.content);
|
||||
// Try to read inline source map
|
||||
sources.map = convert.fromSource(sources.content, options.largeFile);
|
||||
|
||||
if (!sources.map) {
|
||||
return sources;
|
||||
}
|
||||
|
||||
sources.map = sources.map.toObject();
|
||||
// sources in map are relative to the source file
|
||||
sources.path = path.dirname(file.path);
|
||||
if (!options.largeFile) {
|
||||
debug('comment REMOVED');
|
||||
sources.content = convert.removeComments(sources.content);
|
||||
}
|
||||
}
|
||||
|
||||
function _getFileSources(sources) {
|
||||
var debug = rootDebug.spawn('init:internals:loadMaps:_getFileSources');
|
||||
|
||||
// look for source map comment referencing a source map file
|
||||
var mapComment = convert.mapFileCommentRegex.exec(sources.content);
|
||||
|
||||
var mapFile;
|
||||
if (mapComment) {
|
||||
sources.preExistingComment = mapComment[1] || mapComment[2];
|
||||
mapFile = path.resolve(path.dirname(file.path), sources.preExistingComment);
|
||||
sources.content = convert.removeMapFileComments(sources.content);
|
||||
// if no comment try map file with same name as source file
|
||||
} else {
|
||||
mapFile = file.path + '.map';
|
||||
}
|
||||
|
||||
// sources in external map are relative to map file
|
||||
sources.path = path.dirname(mapFile);
|
||||
|
||||
try {
|
||||
sources.map = JSON.parse(stripBom(fs.readFileSync(mapFile, 'utf8')));
|
||||
} catch (e) {
|
||||
debug(function() {
|
||||
return 'warn: external source map not found or invalid: ' + mapFile + ' ' + exceptionToString(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
loadMaps: loadMaps,
|
||||
};
|
||||
};
|
||||
139
node_modules/gulp-sourcemaps/src/init/index.js
generated
vendored
Normal file
139
node_modules/gulp-sourcemaps/src/init/index.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
'use strict';
|
||||
var utils = require('../utils');
|
||||
var unixStylePath = utils.unixStylePath;
|
||||
var through = require('through2');
|
||||
var path = require('path');
|
||||
var acorn = require('acorn');
|
||||
var SourceMapGenerator = require('source-map').SourceMapGenerator;
|
||||
var css = require('css');
|
||||
var initInternals = require('./index.internals');
|
||||
|
||||
/**
|
||||
* Initialize source mapping chain
|
||||
*/
|
||||
function init(options) {
|
||||
var debug = require('../debug').spawn('init');
|
||||
|
||||
function sourceMapInit(file, encoding, callback) {
|
||||
// pass through if file is null or already has a source map
|
||||
if (file.isNull() || file.sourceMap) {
|
||||
this.push(file);
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (file.isStream()) {
|
||||
return callback(new Error(utils.PLUGIN_NAME + '-init: Streaming not supported'));
|
||||
}
|
||||
|
||||
if (options === undefined) {
|
||||
options = {};
|
||||
}
|
||||
debug(function() {
|
||||
return options;
|
||||
});
|
||||
|
||||
var fileContent = file.contents.toString();
|
||||
var sourceMap, preExistingComment;
|
||||
var internals = initInternals(options, file, fileContent);
|
||||
|
||||
if (options.loadMaps) {
|
||||
var result = internals.loadMaps();
|
||||
sourceMap = result.map;
|
||||
fileContent = result.content;
|
||||
preExistingComment = result.preExistingComment;
|
||||
}
|
||||
|
||||
if (!sourceMap && options.identityMap) {
|
||||
debug(function() { return '**identityMap option is deprecated, update to use sourcemap.identityMap stream**'; });
|
||||
debug(function() {
|
||||
return 'identityMap';
|
||||
});
|
||||
var fileType = path.extname(file.path);
|
||||
var source = unixStylePath(file.relative);
|
||||
var generator = new SourceMapGenerator({ file: source });
|
||||
|
||||
if (fileType === '.js') {
|
||||
var tokenizer = acorn.tokenizer(fileContent, { locations: true });
|
||||
while (true) {
|
||||
var token = tokenizer.getToken();
|
||||
if (token.type.label === 'eof') {
|
||||
break;
|
||||
}
|
||||
var mapping = {
|
||||
original: token.loc.start,
|
||||
generated: token.loc.start,
|
||||
source: source,
|
||||
};
|
||||
if (token.type.label === 'name') {
|
||||
mapping.name = token.value;
|
||||
}
|
||||
generator.addMapping(mapping);
|
||||
}
|
||||
generator.setSourceContent(source, fileContent);
|
||||
sourceMap = generator.toJSON();
|
||||
} else if (fileType === '.css') {
|
||||
debug('css');
|
||||
var ast = css.parse(fileContent, { silent: true });
|
||||
debug(function() {
|
||||
return ast;
|
||||
});
|
||||
var registerTokens = function(ast) {
|
||||
if (ast.position) {
|
||||
generator.addMapping({ original: ast.position.start, generated: ast.position.start, source: source });
|
||||
}
|
||||
|
||||
function logAst(key, ast) {
|
||||
debug(function() {
|
||||
return 'key: ' + key;
|
||||
});
|
||||
debug(function() {
|
||||
return ast[key];
|
||||
});
|
||||
}
|
||||
|
||||
for (var key in ast) {
|
||||
logAst(key, ast);
|
||||
if (key !== 'position') {
|
||||
if (Object.prototype.toString.call(ast[key]) === '[object Object]') {
|
||||
registerTokens(ast[key]);
|
||||
} else if (Array.isArray(ast[key])) {
|
||||
debug(function() {
|
||||
return '@@@@ ast[key] isArray @@@@';
|
||||
});
|
||||
for (var i = 0; i < ast[key].length; i++) {
|
||||
registerTokens(ast[key][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
registerTokens(ast);
|
||||
generator.setSourceContent(source, fileContent);
|
||||
sourceMap = generator.toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
if (!sourceMap) {
|
||||
// Make an empty source map
|
||||
sourceMap = {
|
||||
version: 3,
|
||||
names: [],
|
||||
mappings: '',
|
||||
sources: [unixStylePath(file.relative)],
|
||||
sourcesContent: [fileContent],
|
||||
};
|
||||
} else if (preExistingComment !== null && typeof preExistingComment !== 'undefined') {
|
||||
sourceMap.preExistingComment = preExistingComment;
|
||||
}
|
||||
|
||||
sourceMap.file = unixStylePath(file.relative);
|
||||
file.sourceMap = sourceMap;
|
||||
|
||||
this.push(file);
|
||||
callback();
|
||||
}
|
||||
|
||||
return through.obj(sourceMapInit);
|
||||
}
|
||||
|
||||
module.exports = init;
|
||||
77
node_modules/gulp-sourcemaps/src/utils.js
generated
vendored
Normal file
77
node_modules/gulp-sourcemaps/src/utils.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
'use strict';
|
||||
var path = require('path');
|
||||
var detectNewline = require('detect-newline');
|
||||
|
||||
function unixStylePath(filePath) {
|
||||
return filePath.split(path.sep).join('/');
|
||||
}
|
||||
|
||||
var PLUGIN_NAME = require('../package.json').name;
|
||||
|
||||
var urlRegex = /^(https?|webpack(-[^:]+)?):\/\//;
|
||||
|
||||
var debug = require('./debug').spawn('utils');
|
||||
/*
|
||||
So reusing the same ref for a regex (with global (g)) is from a poor decision in js.
|
||||
See http://stackoverflow.com/questions/10229144/bug-with-regexp-in-javascript-when-do-global-search
|
||||
|
||||
So we either need to use a new instance of a regex everywhere.
|
||||
*/
|
||||
function sourceMapUrlRegEx() {
|
||||
return /\/\/# sourceMappingURL=.*/g;
|
||||
}
|
||||
|
||||
var commentFormatters = {
|
||||
css: function cssCommentFormatter(preLine, newline, url) {
|
||||
return preLine + '/*# sourceMappingURL=' + url + ' */' + newline;
|
||||
},
|
||||
js: function jsCommentFormatter(preLine, newline, url) {
|
||||
return preLine + '//# sourceMappingURL=' + url + newline;
|
||||
},
|
||||
default: function defaultFormatter() {
|
||||
return '';
|
||||
},
|
||||
};
|
||||
|
||||
function getCommentFormatter(file) {
|
||||
var extension = file.relative.split('.').pop();
|
||||
var fileContents = file.contents.toString();
|
||||
var newline = detectNewline.graceful(fileContents || '');
|
||||
|
||||
var commentFormatter = commentFormatters.default;
|
||||
|
||||
if (file.sourceMap.preExistingComment) {
|
||||
commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, '', newline);
|
||||
debug(function() {
|
||||
return 'preExistingComment commentFormatter ' + commentFormatter.name;
|
||||
});
|
||||
} else {
|
||||
commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, newline, newline);
|
||||
}
|
||||
|
||||
debug(function() {
|
||||
return 'commentFormatter ' + commentFormatter.name;
|
||||
});
|
||||
return commentFormatter;
|
||||
}
|
||||
|
||||
function getInlinePreExisting(fileContent) {
|
||||
if (sourceMapUrlRegEx().test(fileContent)) {
|
||||
debug(function() { return 'has preExisting'; });
|
||||
return fileContent.match(sourceMapUrlRegEx())[0];
|
||||
}
|
||||
}
|
||||
|
||||
function exceptionToString(exception) {
|
||||
return exception.message || '';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
unixStylePath: unixStylePath,
|
||||
PLUGIN_NAME: PLUGIN_NAME,
|
||||
urlRegex: urlRegex,
|
||||
sourceMapUrlRegEx: sourceMapUrlRegEx,
|
||||
getCommentFormatter: getCommentFormatter,
|
||||
getInlinePreExisting: getInlinePreExisting,
|
||||
exceptionToString: exceptionToString,
|
||||
};
|
||||
177
node_modules/gulp-sourcemaps/src/write/index.internals.js
generated
vendored
Normal file
177
node_modules/gulp-sourcemaps/src/write/index.internals.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(destPath, options) {
|
||||
|
||||
var utils = require('../utils');
|
||||
var unixStylePath = utils.unixStylePath;
|
||||
var fs = require('graceful-fs');
|
||||
var path = require('path');
|
||||
var stripBom = require('strip-bom-string');
|
||||
var rootDebug = require('../debug').spawn('write:internals');
|
||||
|
||||
rootDebug(function() { return 'options'; });
|
||||
rootDebug(function() { return options; });
|
||||
|
||||
function setSourceRoot(file) {
|
||||
var debug = rootDebug.spawn('setSourceRoot');
|
||||
|
||||
var sourceMap = file.sourceMap;
|
||||
if (typeof options.sourceRoot === 'function') {
|
||||
debug(function() { return 'is function'; });
|
||||
sourceMap.sourceRoot = options.sourceRoot(file);
|
||||
} else {
|
||||
debug(function() { return 'from options'; });
|
||||
sourceMap.sourceRoot = options.sourceRoot;
|
||||
}
|
||||
if (sourceMap.sourceRoot === null) {
|
||||
debug(function() { return 'undefined'; });
|
||||
sourceMap.sourceRoot = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function mapSources(file) {
|
||||
var debug = rootDebug.spawn('mapSources');
|
||||
|
||||
// NOTE: make sure source mapping happens after content has been loaded
|
||||
if (options.mapSources && typeof options.mapSources === 'function') {
|
||||
debug(function() { return '**Option is deprecated, update to use sourcemap.mapSources stream**'; });
|
||||
debug(function() { return 'function'; });
|
||||
|
||||
file.sourceMap.sources = file.sourceMap.sources.map(function(filePath) {
|
||||
return options.mapSources(filePath, file);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
debug(function() { return 'file.path: ' + file.path; });
|
||||
debug(function() { return 'file.cwd: ' + file.cwd; });
|
||||
debug(function() { return 'file.base: ' + file.base; });
|
||||
|
||||
file.sourceMap.sources = file.sourceMap.sources.map(function(filePath) {
|
||||
// keep the references files like ../node_modules within the sourceRoot
|
||||
debug(function() { return 'filePath: ' + filePath; });
|
||||
|
||||
if (options.mapSourcesAbsolute === true) {
|
||||
debug(function() { return 'mapSourcesAbsolute'; });
|
||||
|
||||
if (!file.dirname) {
|
||||
debug(function() { return '!file.dirname'; });
|
||||
filePath = path.join(file.base, filePath).replace(file.cwd, '');
|
||||
} else {
|
||||
debug(function() { return 'file.dirname: ' + file.dirname; });
|
||||
filePath = path.resolve(file.dirname, filePath).replace(file.cwd, '');
|
||||
}
|
||||
}
|
||||
return unixStylePath(filePath);
|
||||
});
|
||||
}
|
||||
|
||||
function loadContent(file) {
|
||||
var debug = rootDebug.spawn('loadContent');
|
||||
|
||||
var sourceMap = file.sourceMap;
|
||||
if (options.includeContent) {
|
||||
sourceMap.sourcesContent = sourceMap.sourcesContent || [];
|
||||
|
||||
// load missing source content
|
||||
for (var i = 0; i < sourceMap.sources.length; i++) {
|
||||
if (!sourceMap.sourcesContent[i]) {
|
||||
var sourcePath = path.resolve(file.base, sourceMap.sources[i]);
|
||||
try {
|
||||
debug('No source content for "' + sourceMap.sources[i] + '". Loading from file.');
|
||||
sourceMap.sourcesContent[i] = stripBom(fs.readFileSync(sourcePath, 'utf8'));
|
||||
} catch (e) {
|
||||
debug('source file not found: ' + sourcePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
delete sourceMap.sourcesContent;
|
||||
}
|
||||
}
|
||||
|
||||
function mapDestPath(file, stream) {
|
||||
var debug = rootDebug.spawn('mapDestPath');
|
||||
var sourceMap = file.sourceMap;
|
||||
|
||||
var comment;
|
||||
var commentFormatter = utils.getCommentFormatter(file);
|
||||
|
||||
if (destPath === undefined || destPath === null) {
|
||||
// encode source map into comment
|
||||
var base64Map = new Buffer(JSON.stringify(sourceMap)).toString('base64');
|
||||
comment = commentFormatter('data:application/json;charset=' + options.charset + ';base64,' + base64Map);
|
||||
} else {
|
||||
var mapFile = path.join(destPath, file.relative) + '.map';
|
||||
// custom map file name
|
||||
if (options.mapFile && typeof options.mapFile === 'function') {
|
||||
mapFile = options.mapFile(mapFile);
|
||||
}
|
||||
|
||||
var sourceMapPath = path.join(file.base, mapFile);
|
||||
|
||||
// if explicit destination path is set
|
||||
if (options.destPath) {
|
||||
var destSourceMapPath = path.join(file.cwd, options.destPath, mapFile);
|
||||
var destFilePath = path.join(file.cwd, options.destPath, file.relative);
|
||||
sourceMap.file = unixStylePath(path.relative(path.dirname(destSourceMapPath), destFilePath));
|
||||
if (sourceMap.sourceRoot === undefined) {
|
||||
sourceMap.sourceRoot = unixStylePath(path.relative(path.dirname(destSourceMapPath), file.base));
|
||||
} else if (sourceMap.sourceRoot === '' || (sourceMap.sourceRoot && sourceMap.sourceRoot[0] === '.')) {
|
||||
sourceMap.sourceRoot = unixStylePath(path.join(path.relative(path.dirname(destSourceMapPath), file.base), sourceMap.sourceRoot));
|
||||
}
|
||||
} else {
|
||||
// best effort, can be incorrect if options.destPath not set
|
||||
sourceMap.file = unixStylePath(path.relative(path.dirname(sourceMapPath), file.path));
|
||||
if (sourceMap.sourceRoot === '' || (sourceMap.sourceRoot && sourceMap.sourceRoot[0] === '.')) {
|
||||
sourceMap.sourceRoot = unixStylePath(path.join(path.relative(path.dirname(sourceMapPath), file.base), sourceMap.sourceRoot));
|
||||
}
|
||||
}
|
||||
|
||||
var sourceMapFile = file.clone(options.clone || { deep: false, contents: false });
|
||||
sourceMapFile.path = sourceMapPath;
|
||||
sourceMapFile.contents = new Buffer(JSON.stringify(sourceMap));
|
||||
sourceMapFile.stat = {
|
||||
isFile: function() { return true; },
|
||||
isDirectory: function() { return false; },
|
||||
isBlockDevice: function() { return false; },
|
||||
isCharacterDevice: function() { return false; },
|
||||
isSymbolicLink: function() { return false; },
|
||||
isFIFO: function() { return false; },
|
||||
isSocket: function() { return false; },
|
||||
};
|
||||
stream.push(sourceMapFile);
|
||||
|
||||
var sourceMapPathRelative = path.relative(path.dirname(file.path), sourceMapPath);
|
||||
|
||||
if (options.sourceMappingURLPrefix) {
|
||||
var prefix = '';
|
||||
if (typeof options.sourceMappingURLPrefix === 'function') {
|
||||
prefix = options.sourceMappingURLPrefix(file);
|
||||
} else {
|
||||
prefix = options.sourceMappingURLPrefix;
|
||||
}
|
||||
sourceMapPathRelative = prefix + path.join('/', sourceMapPathRelative);
|
||||
}
|
||||
debug(function() { return 'destPath comment'; });
|
||||
comment = commentFormatter(unixStylePath(sourceMapPathRelative));
|
||||
|
||||
if (options.sourceMappingURL && typeof options.sourceMappingURL === 'function') {
|
||||
debug(function() { return 'options.sourceMappingURL comment'; });
|
||||
comment = commentFormatter(options.sourceMappingURL(file));
|
||||
}
|
||||
}
|
||||
|
||||
// append source map comment
|
||||
if (options.addComment) {
|
||||
file.contents = Buffer.concat([file.contents, new Buffer(comment)]);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setSourceRoot: setSourceRoot,
|
||||
loadContent: loadContent,
|
||||
mapSources: mapSources,
|
||||
mapDestPath: mapDestPath,
|
||||
};
|
||||
};
|
||||
69
node_modules/gulp-sourcemaps/src/write/index.js
generated
vendored
Normal file
69
node_modules/gulp-sourcemaps/src/write/index.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
var utils = require('../utils');
|
||||
var through = require('through2');
|
||||
var unixStylePath = utils.unixStylePath;
|
||||
var internalsInit = require('./index.internals');
|
||||
|
||||
/**
|
||||
* Write the source map
|
||||
*
|
||||
* @param options options to change the way the source map is written
|
||||
*
|
||||
*/
|
||||
function write(destPath, options) {
|
||||
var debug = require('../debug').spawn('write');
|
||||
|
||||
debug(function() { return 'destPath'; });
|
||||
debug(function() { return destPath; });
|
||||
|
||||
debug(function() { return 'original options';});
|
||||
debug(function() { return options; });
|
||||
|
||||
if (options === undefined && typeof destPath !== 'string') {
|
||||
options = destPath;
|
||||
destPath = undefined;
|
||||
}
|
||||
options = options || {};
|
||||
|
||||
// set defaults for options if unset
|
||||
if (options.includeContent === undefined) {
|
||||
options.includeContent = true;
|
||||
}
|
||||
if (options.addComment === undefined) {
|
||||
options.addComment = true;
|
||||
}
|
||||
if (options.charset === undefined) {
|
||||
options.charset = 'utf8';
|
||||
}
|
||||
|
||||
debug(function() { return 'derrived options'; });
|
||||
debug(function() { return options; });
|
||||
|
||||
var internals = internalsInit(destPath, options);
|
||||
|
||||
function sourceMapWrite(file, encoding, callback) {
|
||||
if (file.isNull() || !file.sourceMap) {
|
||||
this.push(file);
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (file.isStream()) {
|
||||
return callback(new Error(utils.PLUGIN_NAME + '-write: Streaming not supported'));
|
||||
}
|
||||
|
||||
// fix paths if Windows style paths
|
||||
file.sourceMap.file = unixStylePath(file.relative);
|
||||
|
||||
internals.setSourceRoot(file);
|
||||
internals.loadContent(file);
|
||||
internals.mapSources(file);
|
||||
internals.mapDestPath(file, this);
|
||||
|
||||
this.push(file);
|
||||
callback();
|
||||
}
|
||||
|
||||
return through.obj(sourceMapWrite);
|
||||
}
|
||||
|
||||
module.exports = write;
|
||||
Reference in New Issue
Block a user