This commit is contained in:
hatuhn
2019-09-13 09:45:04 +07:00
parent f14a34ba19
commit 558fb07261
16790 changed files with 0 additions and 1642370 deletions

View File

@@ -1,39 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="4.2.1"></a>
## [4.2.1](https://github.com/klei/gulp-inject/compare/v4.2.0...v4.2.1) (2017-09-15)
### Bug Fixes
* **endtag:** use correct default for endtag ([#228](https://github.com/klei/gulp-inject/issues/228)) ([687bfdf](https://github.com/klei/gulp-inject/commit/687bfdf)), closes [#224](https://github.com/klei/gulp-inject/issues/224)
<a name="4.2.0"></a>
# [4.2.0](https://github.com/klei/gulp-inject/compare/v4.1.0...v4.2.0) (2016-12-20)
### Features
* **tags:** add {{path}} parsing to 'start-' and 'endtag' ([#175](https://github.com/klei/gulp-inject/issues/175)) ([503b77e](https://github.com/klei/gulp-inject/commit/503b77e))
<a name="4.1.0"></a>
# [4.1.0](https://github.com/klei/gulp-inject/compare/v4.0.0...v4.1.0) (2016-05-18)
### Bug Fixes
* don't remove wanted whitespace when removing tags (closes [#177](https://github.com/klei/gulp-inject/issues/177)) ([8078cd9](https://github.com/klei/gulp-inject/commit/8078cd9)), closes [#177](https://github.com/klei/gulp-inject/issues/177)
* don't use ES2015 syntax (closes [#171](https://github.com/klei/gulp-inject/issues/171)) ([68add8a](https://github.com/klei/gulp-inject/commit/68add8a)), closes [#171](https://github.com/klei/gulp-inject/issues/171)
* making it possible to inject source map files into html (closes [#176](https://github.com/klei/gulp-inject/issues/176)) ([7649b38](https://github.com/klei/gulp-inject/commit/7649b38)), closes [#176](https://github.com/klei/gulp-inject/issues/176)
* only log file count for files actually injected (closes [#184](https://github.com/klei/gulp-inject/issues/184)) ([b4fd0d6](https://github.com/klei/gulp-inject/commit/b4fd0d6)), closes [#184](https://github.com/klei/gulp-inject/issues/184)
### Features
* support pug templates (PR [#185](https://github.com/klei/gulp-inject/issues/185), closes [#181](https://github.com/klei/gulp-inject/issues/181)) ([195df4e](https://github.com/klei/gulp-inject/commit/195df4e)), closes [#181](https://github.com/klei/gulp-inject/issues/181)

20
node_modules/gulp-inject/LICENSE generated vendored
View File

@@ -1,20 +0,0 @@
Copyright 2014
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.

976
node_modules/gulp-inject/README.md generated vendored
View File

@@ -1,976 +0,0 @@
# gulp-inject
---
## HELP WANTED
### Contributors are welcomed!
**I don't have enough time to maintain this plugin as I would want to, so I'm looking for people who want to help out and be contributors/repository admins.**
#### Interested?
**Contact me! See `package.json` for contact information.**
---
[![NPM version][npm-image]][npm-url] [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Build Status][travis-image]][travis-url] [![XO code style][codestyle-image]][codestyle-url] [![Dependency Status][depstat-image]][depstat-url]
> A stylesheet, javascript and webcomponent reference injection plugin for [gulp](https://github.com/wearefractal/gulp). No more manual editing of your index.html!
# Contents
<!-- MDTOC maxdepth:3 firsth1:0 numbering:0 flatten:0 bullets:1 updateOnSave:1 -->
- [Introduction](#introduction)
- [Installation](#installation)
- [Basic usage](#basic-usage)
- [More examples](#more-examples)
- [Injecting files relative to target files](#injecting-files-relative-to-target-files)
- [Injecting files from multiple source streams](#injecting-files-from-multiple-source-streams)
- [Multiple sources when order is important](#multiple-sources-when-order-is-important)
- [Injecting some files into `<head>` and some into `<body>`](#injecting-some-files-into-head-and-some-into-body)
- [Method 1: Use `gulp-inject`'s `starttag` option.](#method-1-use-gulp-injects-starttag-option)
- [Method 2: Use `gulp-inject`'s `name` option.](#method-2-use-gulp-injects-name-option)
- [Injecting all files for development](#injecting-all-files-for-development)
- [Injecting AngularJS scripts for development](#injecting-angularjs-scripts-for-development)
- [Injecting into a json-file](#injecting-into-a-json-file)
- [Injecting with custom `transform` function with default fallback](#injecting-with-custom-transform-function-with-default-fallback)
- [Injecting dist files into bower.json's main section](#injecting-dist-files-into-bowerjsons-main-section)
- [Injecting all javascript files into a karma config file](#injecting-all-javascript-files-into-a-karma-config-file)
- [Injecting files contents](#injecting-files-contents)
- [Injecting files contents based on file path](#injecting-files-contents-based-on-file-path)
- [API](#api)
- [inject(sources, options)](#injectsources-options)
- [Options](#options)
- [options.ignorePath](#optionsignorepath)
- [options.relative](#optionsrelative)
- [options.addPrefix](#optionsaddprefix)
- [options.addSuffix](#optionsaddsuffix)
- [options.addRootSlash](#optionsaddrootslash)
- [options.name](#optionsname)
- [options.removeTags](#optionsremovetags)
- [options.empty](#optionsempty)
- [options.starttag](#optionsstarttag)
- [options.endtag](#optionsendtag)
- [options.transform](#optionstransform)
- [options.selfClosingTag](#optionsselfclosingtag)
- [~~options.templateString~~](#optionstemplatestring)
- [~~options.sort~~](#optionssort)
- [inject.transform](#injecttransform)
- [License](#license)
<!-- /MDTOC -->
## Introduction
`gulp-inject` takes a stream of source files, transforms each file to a string and injects each transformed string into placeholders in the target stream files. See [Basic usage](#basic-usage) and [More examples](#more-examples) below.
Default [transforms](#optionstransform) and [placeholders](#optionsstarttag) exists for injecting files into `html`, `jade`, `pug`, `jsx` , `less`, `slm`, `haml` and `sass` / `scss` files.
## Installation
Install `gulp-inject` as a development dependency:
```shell
npm install --save-dev gulp-inject
```
## Basic usage
**The target file `src/index.html`:**
Each pair of comments are the injection placeholders (aka. tags, see [`options.starttag`](#optionsstarttag) and [`options.endtag`](#optionsendtag)).
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- inject:css -->
<!-- endinject -->
</head>
<body>
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
```
**The `gulpfile.js`:**
```javascript
var gulp = require('gulp');
var inject = require('gulp-inject');
gulp.task('index', function () {
var target = gulp.src('./src/index.html');
// It's not necessary to read the files (will speed up things), we're only after their paths:
var sources = gulp.src(['./src/**/*.js', './src/**/*.css'], {read: false});
return target.pipe(inject(sources))
.pipe(gulp.dest('./src'));
});
```
**`src/index.html` after running `gulp index`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- inject:css -->
<link rel="stylesheet" href="/src/style1.css">
<link rel="stylesheet" href="/src/style2.css">
<!-- endinject -->
</head>
<body>
<!-- inject:js -->
<script src="/src/lib1.js"></script>
<script src="/src/lib2.js"></script>
<!-- endinject -->
</body>
</html>
```
## More examples
### Injecting files relative to target files
By default the injected file paths are relative to each source file's `cwd` (see [`options.ignorePath`](#optionsignorepath)). If `options.relative` is set to `true` each injected path will be relative to each target file's directory instead.
**Project structure:**
```
└── src
├── module
│ ├── module.js
│ └── module.html
└── app
├── main.js
└── index.html
```
**`src/app/index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My Index</title>
</head>
<body>
<h1>Home</h1>
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
```
**`src/module/module.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>Module</title>
</head>
<body>
<h1>Module</h1>
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
```
**`gulpfile.js`:**
```javascript
var inject = require('gulp-inject');
gulp.src('./src/**/*.html')
.pipe(inject(gulp.src('./src/**/*.js', {read: false}), {relative: true}))
.pipe(gulp.dest('./src'));
```
**Resulting `src/app/index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My Index</title>
</head>
<body>
<h1>Home</h1>
<!-- inject:js -->
<script src="main.js"></script>
<script src="../module/module.js"></script>
<!-- endinject -->
</body>
</html>
```
**Resulting `src/module/module.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>Module</title>
</head>
<body>
<h1>Home</h1>
<!-- inject:js -->
<script src="../app/main.js"></script>
<script src="module.js"></script>
<!-- endinject -->
</body>
</html>
```
### Injecting files from multiple source streams
This example demonstrates how to inject files from multiple different streams into the same injection placeholder.
Install [`event-stream`](https://www.npmjs.org/package/event-stream) with: `npm install --save-dev event-stream` and use its [`merge`](https://github.com/dominictarr/event-stream#merge-stream1streamn) function.
**Code:**
```javascript
var es = require('event-stream'),
inject = require('gulp-inject'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
// Concatenate vendor scripts
var vendorStream = gulp.src(['./src/vendors/*.js'])
.pipe(concat('vendors.js'))
.pipe(gulp.dest('./dist'));
// Concatenate AND minify app sources
var appStream = gulp.src(['./src/app/*.js'])
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
gulp.src('./src/index.html')
.pipe(inject(es.merge(vendorStream, appStream)))
.pipe(gulp.dest('./dist'));
```
#### Multiple sources when order is important
Use [`stream-series`](https://github.com/rschmukler/stream-series).
**Code:**
```javascript
var series = require('stream-series'),
inject = require('gulp-inject');
var vendorStream = gulp.src(['./src/vendors/*.js'], {read: false});
var appStream = gulp.src(['./src/app/*.js'], {read: false});
gulp.src('./src/index.html')
.pipe(inject(series(vendorStream, appStream))) // This will always inject vendor files before app files
.pipe(gulp.dest('./dist'));
```
### Injecting some files into `<head>` and some into `<body>`
#### Method 1: Use `gulp-inject`'s `starttag` option.
**`gulpfile.js`:**
```javascript
var inject = require('gulp-inject');
gulp.src('./src/index.html')
.pipe(inject(gulp.src('./src/importantFile.js', {read: false}), {starttag: '<!-- inject:head:{{ext}} -->'}))
.pipe(inject(gulp.src(['./src/*.js', '!./src/importantFile.js'], {read: false})))
.pipe(gulp.dest('./dist'));
```
**And in your `./src/index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- inject:head:js -->
<!-- only importantFile.js will be injected here -->
<!-- endinject -->
</head>
<body>
<!-- inject:js -->
<!-- the rest of the *.js files will be injected here -->
<!-- endinject -->
</body>
</html>
```
#### Method 2: Use `gulp-inject`'s `name` option.
**`gulpfile.js`:**
```javascript
var inject = require('gulp-inject');
gulp.src('./src/index.html')
.pipe(inject(gulp.src('./src/importantFile.js', {read: false}), {name: 'head'}))
.pipe(inject(gulp.src(['./src/*.js', '!./src/importantFile.js'], {read: false})))
.pipe(gulp.dest('./dist'));
```
**And in your `./src/index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- head:js -->
<!-- only importantFile.js will be injected here -->
<!-- endinject -->
</head>
<body>
<!-- inject:js -->
<!-- the rest of the *.js files will be injected here -->
<!-- endinject -->
</body>
</html>
```
### Injecting all files for development
If you use [Bower](http://bower.io/) for frontend dependencies I recommend using [`main-bower-files`](https://www.npmjs.org/package/main-bower-files) and injecting them as well.
**`gulpfile.js`:**
```javascript
var bowerFiles = require('main-bower-files'),
inject = require('gulp-inject'),
stylus = require('gulp-stylus'),
es = require('event-stream');
var cssFiles = gulp.src('./src/**/*.styl')
.pipe(stylus())
.pipe(gulp.dest('./build'));
gulp.src('./src/index.html')
.pipe(inject(gulp.src(bowerFiles(), {read: false}), {name: 'bower'}))
.pipe(inject(es.merge(
cssFiles,
gulp.src('./src/app/**/*.js', {read: false})
)))
.pipe(gulp.dest('./build'));
```
**`src/index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- bower:css -->
<!-- bower installed css files will go here... -->
<!-- endinject -->
<!-- inject:css -->
<!-- built css files will go here... -->
<!-- endinject -->
</head>
<body>
<!-- bower:js -->
<!-- bower installed scripts will go here... -->
<!-- endinject -->
<!-- inject:js -->
<!-- app scripts will go here... -->
<!-- endinject -->
</body>
</html>
```
**Note** remember to mount `./bower_components`, `./build` and `./src/app` as static resources in your server to make this work.
### Injecting AngularJS scripts for development
If you're writing an AngularJS application and follow [Google's Angular APP Structure Recommendations](https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub), which I think you should, it's important that the script files are injected in the correct order to avoid module instantiation problems like `Uncaught Error: [$injector:modulerr]`.
To do this you can use [`gulp-angular-filesort`](https://www.npmjs.org/package/gulp-angular-filesort) together with `gulp-inject` like so:
```javascript
var angularFilesort = require('gulp-angular-filesort'),
inject = require('gulp-inject');
gulp.src('./src/index.html')
.pipe(inject(
gulp.src('./src/app/**/*.js') // gulp-angular-filesort depends on file contents, so don't use {read: false} here
.pipe(angularFilesort())
))
.pipe(gulp.dest('./build'));
```
### Injecting into a json-file
You can customize `gulp-inject` further by using the `transform` function option, e.g. by injecting files into a json-file.
**Code:**
```javascript
gulp.src('./files.json')
.pipe(inject(gulp.src(['./src/*.js', './src/*.css', './src/*.html'], {read: false}), {
starttag: '"{{ext}}": [',
endtag: ']',
transform: function (filepath, file, i, length) {
return ' "' + filepath + '"' + (i + 1 < length ? ',' : '');
}
}))
.pipe(gulp.dest('./'));
```
Initial contents of `files.json`:
```json
{
"js": [
],
"css": [
],
"html": [
]
}
```
### Injecting with custom `transform` function with default fallback
The [default `transform`](#injecttransform) function is available to use e.g. as a default fallback.
Used here to inject Word documents as `<a>` tags below:
**`index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My documents</title>
</head>
<body>
<h1>Documents</h1>
<ul>
<!-- inject:docx -->
<!-- endinject -->
</ul>
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
```
**`gulpfile.js`:**
```javascript
var inject = require('gulp-inject');
gulp.src('./index.html')
.pipe(inject(
gulp.src(['./*.js', './docs/*.docx'], {read: false}), {
transform: function (filepath) {
if (filepath.slice(-5) === '.docx') {
return '<li><a href="' + filepath + '">' + filepath + '</a></li>';
}
// Use the default transform as fallback:
return inject.transform.apply(inject.transform, arguments);
}
}
))
.pipe(gulp.dest('./'));
```
**Resulting `index.html`:**
```html
<!DOCTYPE html>
<html>
<head>
<title>My documents</title>
</head>
<body>
<h1>Documents</h1>
<ul>
<!-- inject:docx -->
<li><a href="/docs/document1.docx"></a></li>
<li><a href="/docs/document2.docx"></a></li>
<!-- endinject -->
</ul>
<!-- inject:js -->
<script src="/lib1.js"></script>
<script src="/lib2.js"></script>
<!-- endinject -->
</body>
</html>
```
### Injecting dist files into bower.json's main section
**Code:**
```javascript
gulp.src('./bower.json')
.pipe(inject(gulp.src(['./dist/app.min.js', './dist/app.min.css'], {read: false}), {
starttag: '"main": [',
endtag: ']',
transform: function (filepath, file, i, length) {
return ' "' + filepath + '"' + (i + 1 < length ? ',' : '');
}
}))
.pipe(gulp.dest('./'));
```
### Injecting all javascript files into a karma config file
**Code:**
```javascript
gulp.src('./karma.conf.js')
.pipe(inject(gulp.src(['./src/**/*.js'], {read: false}), {
starttag: 'files: [',
endtag: ']',
transform: function (filepath, file, i, length) {
return ' "' + filepath + '"' + (i + 1 < length ? ',' : '');
}
}))
.pipe(gulp.dest('./'));
```
### Injecting files contents
In order to inject files contents you have to provide custom `transform` function, that will return file contents as string. You also have to omit `{read: false}` option of `gulp.src` in this case. Example below shows how to inject contents of html partials into head of `index.html`:
***Code:***
```javascript
gulp.src('./src/index.html')
.pipe(inject(gulp.src(['./src/partials/head/*.html']), {
starttag: '<!-- inject:head:{{ext}} -->',
transform: function (filePath, file) {
// return file contents as string
return file.contents.toString('utf8')
}
}))
.pipe(gulp.dest('./dest'));
```
And in your `./src/index.html`:
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- inject:head:html -->
<!-- contents of html partials will be injected here -->
<!-- endinject -->
</head>
<body>
</body>
</html>
```
### Injecting files contents based on file path
In order to inject files based on file path you have to provide custom `starttag` which includes `{{path}}`. Additionally, in order to inject file contents include `transform` function, that will return file contents as string. You also have to omit `{read: false}` option of `gulp.src` in this case. Path can be either absolute, or relative in which case you should set [`options.relative`] to true. Example below shows how to inject contents of html partials into `index.html`:
***Code:***
```javascript
gulp.src('./src/index.html')
.pipe(inject(gulp.src(['./src/partials/head/*.html']), {
starttag: '<!-- inject:{{path}} -->',
relative: true,
transform: function (filePath, file) {
// return file contents as string
return file.contents.toString('utf8')
}
}))
.pipe(gulp.dest('./dest'));
```
And in your `./src/index.html`:
```html
<!DOCTYPE html>
<html>
<head>
<title>My index</title>
<!-- inject:path/to/your/file.ext -->
<!-- contents of html partials will be injected here -->
<!-- endinject -->
</head>
<body>
</body>
</html>
```
## API
### inject(sources, options)
Parameter: `sources`
Type: `Stream`
Provide a Vinyl File Stream as input to `inject`, see examples above.
Parameter: `options`
Type: `Object`
For available options see [Options](#options)
### Options
#### options.ignorePath
Type: `String` or `Array`
Default: `NULL`
A path or paths that should be removed from each injected file path.
This could also be solved by setting the `cwd` option for your `gulp.src` streams, each source file's `cwd` is automatically removed from its path before injection (if not [`options.relative`](#optionsrelative) is set to `true`, see below).
#### options.relative
Type: `Boolean`
Default: `false`
If set to `true` paths for the injected files will be relative to each target file, this also means that each source file's `cwd` is not necessary to remove from its path.
#### options.addPrefix
Type: `String`
Default: `NULL`
A path that should be prefixed to each injected file path.
#### options.addSuffix
Type: `String`
Default: `NULL`
A path that should be suffixed to each injected file path.
#### options.addRootSlash
Type: `Boolean`
Default: [`!options.relative`](#optionsrelative)
The root slash is automatically added at the beginning of the path ('/'), or removed if set to `false`.
#### options.name
Type: `String`
Default: `"inject"`
Used in the default [start](#optionsstarttag) and [end](#optionsendtag) tags below.
#### options.removeTags
Type: `Boolean`
Default: `false`
When `true` the start and end tags will be removed when injecting files.
#### options.empty
Type: `Boolean`
Default: `false`
When `true` all tags without corresponding files will be emptied.
[**Warning** this has the potential issue of emptying more than expected.](https://github.com/klei/gulp-inject/issues/135)
#### options.starttag
**Type:** `String`|`Function(targetExt, sourceExt)`
**Params (if function):**
- `targetExt` - The file extension of the target file
- `sourceExt` - The file extension of source file
**Purpose:**
Used to dynamically set starting placeholder tag depending on file extensions.
In the provided string, or the string returned from the given function, the string `{{ext}}` is replaced with the source file extension name, e.g. "css", "js" or "html". `{{name}}` will be replaced by [`options.name`](#optionsname). `{{path}}` will be replaced by path to source file (when used together with [`options.relative`] it will allow relative path to source file.
##### Default:
A function dependent on target file type and source file type that returns:
* html as target: `<!-- {{name}}:{{ext}} -->`
* haml as target: `-# {{name}}:{{ext}}`
* jade as target: `//- {{name}}:{{ext}}`
* pug as target: `//- {{name}}:{{ext}}`
* jsx as target: `{/* {{name}}:{{ext}} */}`
* slm as target: `/ {{name}}:{{ext}}`
* less as target: `/* {{name}}:{{ext}} */`
* sass, scss as target: `/* {{name}}:{{ext}} */`
#### options.endtag
**Type:** `String`|`Function(targetExt, sourceExt)`
**Params (if function):**
- `targetExt` - The file extension of the target file
- `sourceExt` - The file extension of source file
**Purpose:**
Used to dynamically set ending placeholder tag depending on file extensions.
In the provided string, or the string returned from the given function, the string `{{ext}}` is replaced with the source file extension name, e.g. "css", "js" or "html". `{{name}}` will be replaced by [`options.name`](#optionsname). `{{path}}` will be replaced by path to source file.
##### Default:
A function dependent on target file type and source file type that returns:
* html as target: `<!-- endinject -->`
* haml as target: `-# endinject`
* jade as target: `//- endinject`
* pug as target: `//- endinject`
* jsx as target: `{/* endinject */}`
* slm as target: `/ endinject`
* less as target: `/* endinject */`
* sass, scss as target: `/* endinject */`
#### options.transform
**Type**: `Function(filepath, file, index, length, targetFile)`
**Params:**
- `filepath` - The "unixified" path to the file with any `ignorePath`'s removed, `addPrefix` and `addSuffix` added
- `file` - The [File object](https://github.com/wearefractal/vinyl) to inject given from `gulp.src`
- `index` - 0-based file index
- `length` - Total number of files to inject for the current file extension
- `targetFile` - The target [file](https://github.com/wearefractal/vinyl) to inject into
**Purpose:**
Used to generate the content to inject for each file.
##### Default:
[A function](#injecttransform) dependent on target file type and source file type that returns:
**Injecting into `html`**
* css files: `<link rel="stylesheet" href="<filename>.css">`
* js files: `<script src="<filename>.js"></script>`
* coffee files: `<script type="text/coffeescript" src="<filename>.coffee"></script>`
* html files: `<link rel="import" href="<filename>.html">`
* png files: `<img src="<filename>.png">`
* gif files: `<img src="<filename>.gif">`
* jpg files: `<img src="<filename>.jpg">`
* jpeg files: `<img src="<filename>.jpeg">`
If `options.selfClosingTag` is `true` the default transformer above will make the `<link>` and `<img>` tags self close, i.e: `<link ... />` and `<img ... />` respectively.
**Injecting into `jsx`**
The same as for injecting into `html` above with [`options.selfClosingTag`](#optionsselfclosingtag) set to `true`.
**Injecting into `jade`**
* css files: `link(rel="stylesheet", href="<filename>.css")`
* js files: `script(src="<filename>.js")`
* coffee files: `script(type="text/coffeescript", src="<filename>.coffee")`
* html files: `link(rel="import", href="<filename>.html")`
* png files: `img(src="<filename>.png")`
* gif files: `img(src="<filename>.gif")`
* jpg files: `img(src="<filename>.jpg")`
* jpeg files: `img(src="<filename>.jpeg")`
**Injecting into `pug`**
* css files: `link(rel="stylesheet", href="<filename>.css")`
* js files: `script(src="<filename>.js")`
* coffee files: `script(type="text/coffeescript", src="<filename>.coffee")`
* html files: `link(rel="import", href="<filename>.html")`
* png files: `img(src="<filename>.png")`
* gif files: `img(src="<filename>.gif")`
* jpg files: `img(src="<filename>.jpg")`
* jpeg files: `img(src="<filename>.jpeg")`
**Injecting into `slm`**
* css files: `link rel="stylesheet" href="<filename>.css"`
* js files: `script src="<filename>.js"`
* coffee files: `script type="text/coffeescript" src="<filename>.coffee"`
* html files: `link rel="import" href="<filename>.html"`
* png files: `img src="<filename>.png"`
* gif files: `img src="<filename>.gif"`
* jpg files: `img src="<filename>.jpg"`
* jpeg files: `img src="<filename>.jpeg"`
**Injecting into `haml`**
* css files: `%link{rel:"stylesheet", href:"<filename>.css"}`
* js files: `%script{src:"<filename>.js"}`
* coffee files: `%script{type:"text/coffeescript", src:"<filename>.coffee"}`
* html files: `%link{rel:"import", href:"<filename>.html"}`
* png files: `%img{src:"<filename>.png"}`
* gif files: `%img{src:"<filename>.gif"}`
* jpg files: `%img{src:"<filename>.jpg"}`
* jpeg files: `%img{src:"<filename>.jpeg"}`
**Injecting into `less`**
* css files: `@import "<filename>.css";`
* less files: `@import "<filename>.less";`
**Injecting into `scss`**
* css files: `@import "<filename>.css";`
* scss files: `@import "<filename>.scss";`
* sass files: `@import "<filename>.sass";`
**Injecting into `sass`**
* css files: `@import "<filename>.css"`
* sass files: `@import "<filename>.sass"`
* scss files: `@import "<filename>.scss"`
#### options.selfClosingTag
Type: `Boolean`
Default: `false`
Affects the default `options.transform` function, see above.
#### options.quiet
Type: `Boolean`
Default: `false`
Lower the verbosity by setting this to true, suppressing the logging of successful injections.
#### ~~options.templateString~~
***DEPRECATED!***
*Deprecated since `v.1.0`. Use [`gulp-file`](https://www.npmjs.org/package/gulp-file) instead:*
```javascript
var gulp = require('gulp');
var file = require('gulp-file');
var inject = require('gulp-inject');
file('index.html', '<html><head></head></html>')
.pipe(inject(gulp.src(['./src/app/**/*.js']), {
starttag: '<head>',
endtag: '</head>'
}))
.pipe(gulp.dest('./dest'));
```
#### ~~options.sort~~
***DEPRECATED!***
*Deprecated since `v.1.0`. Use [`sort-stream`](https://www.npmjs.org/package/sort-stream) instead:*
```javascript
var gulp = require('gulp');
var sort = require('sort-stream');
var inject = require('gulp-inject');
gulp.src('index.html')
.pipe(inject(
gulp.src(['./src/app/**/*.js'])
.pipe(sort(function (a, b) {
// Sort condition here...
}))
))
.pipe(gulp.dest('./dest'));
```
### inject.transform
The default transform function is exposed in the public API.
For more details see [the code with tests](https://github.com/klei/gulp-inject/tree/master/src/transform).
##### inject.transform.html
The default transform function for files into `html`, or other file types not `jade`, `pug`, `jsx`, `slm`, `less`, `scss`, `sass` or `haml`.
##### inject.transform.jade
The default transform function for files into `jade`.
##### inject.transform.pug
The default transform function for files into `pug`.
##### inject.transform.jsx
The default transform function for files into `jsx`.
##### inject.transform.slm
The default transform function for files into `slm`.
##### inject.transform.haml
The default transform function for files into `haml`.
##### inject.transform.less
The default transform function for files into `less`.
##### inject.transform.sass
The default transform function for files into `sass`.
##### inject.transform.scss
The default transform function for files into `scss`.
## License
[MIT](http://en.wikipedia.org/wiki/MIT_License) © [Joakim Carlstein](http://joakim.beng.se)
[npm-url]: https://npmjs.org/package/gulp-inject
[npm-image]: https://badge.fury.io/js/gulp-inject.svg
[travis-url]: http://travis-ci.org/klei/gulp-inject
[travis-image]: https://secure.travis-ci.org/klei/gulp-inject.svg?branch=master
[depstat-url]: https://david-dm.org/klei/gulp-inject
[depstat-image]: https://david-dm.org/klei/gulp-inject.svg
[codestyle-url]: https://github.com/sindresorhus/xo
[codestyle-image]: https://img.shields.io/badge/code%20style-XO-5ed9c7.svg?style=flat

View File

@@ -1,5 +0,0 @@
'use strict';
module.exports = {
extends: ['@commitlint/config-angular']
};

9
node_modules/gulp-inject/index.js generated vendored
View File

@@ -1,9 +0,0 @@
/**
* Export `gulp-inject`
*/
module.exports = exports = require('./src/inject');
/**
* Export the default transform function(s)
*/
exports.transform = require('./src/transform');

View File

@@ -1,24 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014-2015 Jon Schlinkert.
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.

View File

@@ -1,75 +0,0 @@
# arr-diff [![NPM version](https://badge.fury.io/js/arr-diff.svg)](http://badge.fury.io/js/arr-diff) [![Build Status](https://travis-ci.org/jonschlinkert/arr-diff.svg)](https://travis-ci.org/jonschlinkert/arr-diff)
> Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.
## Install
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i arr-diff --save
```
Install with [bower](http://bower.io/)
```sh
$ bower install arr-diff --save
```
## API
### [diff](index.js#L33)
Return the difference between the first array and additional arrays.
**Params**
* `a` **{Array}**
* `b` **{Array}**
* `returns` **{Array}**
**Example**
```js
var diff = require('arr-diff');
var a = ['a', 'b', 'c', 'd'];
var b = ['b', 'c'];
console.log(diff(a, b))
//=> ['a', 'd']
```
## Related projects
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten)
* [array-filter](https://www.npmjs.com/package/array-filter): Array#filter for older browsers. | [homepage](https://github.com/juliangruber/array-filter)
* [array-intersection](https://www.npmjs.com/package/array-intersection): Return an array with the unique values present in _all_ given arrays using strict equality… [more](https://www.npmjs.com/package/array-intersection) | [homepage](https://github.com/jonschlinkert/array-intersection)
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-diff/issues/new).
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 23, 2015._

View File

@@ -1,58 +0,0 @@
/*!
* arr-diff <https://github.com/jonschlinkert/arr-diff>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT License
*/
'use strict';
var flatten = require('arr-flatten');
var slice = require('array-slice');
/**
* Return the difference between the first array and
* additional arrays.
*
* ```js
* var diff = require('{%= name %}');
*
* var a = ['a', 'b', 'c', 'd'];
* var b = ['b', 'c'];
*
* console.log(diff(a, b))
* //=> ['a', 'd']
* ```
*
* @param {Array} `a`
* @param {Array} `b`
* @return {Array}
* @api public
*/
function diff(arr, arrays) {
var argsLen = arguments.length;
var len = arr.length, i = -1;
var res = [], arrays;
if (argsLen === 1) {
return arr;
}
if (argsLen > 2) {
arrays = flatten(slice(arguments, 1));
}
while (++i < len) {
if (!~arrays.indexOf(arr[i])) {
res.push(arr[i]);
}
}
return res;
}
/**
* Expose `diff`
*/
module.exports = diff;

View File

@@ -1,80 +0,0 @@
{
"_from": "arr-diff@^1.0.1",
"_id": "arr-diff@1.1.0",
"_inBundle": false,
"_integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
"_location": "/gulp-inject/arr-diff",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "arr-diff@^1.0.1",
"name": "arr-diff",
"escapedName": "arr-diff",
"rawSpec": "^1.0.1",
"saveSpec": null,
"fetchSpec": "^1.0.1"
},
"_requiredBy": [
"/gulp-inject/plugin-error"
],
"_resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
"_shasum": "687c32758163588fef7de7b36fabe495eb1a399a",
"_spec": "arr-diff@^1.0.1",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject/node_modules/plugin-error",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/arr-diff/issues"
},
"bundleDependencies": false,
"dependencies": {
"arr-flatten": "^1.0.1",
"array-slice": "^0.2.3"
},
"deprecated": false,
"description": "Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.",
"devDependencies": {
"array-differ": "^1.0.0",
"benchmarked": "^0.1.4",
"chalk": "^1.1.1",
"mocha": "^2.2.5",
"should": "^7.0.4"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/arr-diff",
"keywords": [
"arr",
"array",
"diff",
"differ",
"difference"
],
"license": "MIT",
"main": "index.js",
"name": "arr-diff",
"repository": {
"type": "git",
"url": "git+https://github.com/jonschlinkert/arr-diff.git"
},
"scripts": {
"test": "mocha"
},
"verb": {
"related": {
"list": [
"arr-flatten",
"array-filter",
"array-intersection"
]
}
},
"version": "1.1.0"
}

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014-2015, Jon Schlinkert.
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.

View File

@@ -1,85 +0,0 @@
# arr-union [![NPM version](https://badge.fury.io/js/arr-union.svg)](http://badge.fury.io/js/arr-union) [![Build Status](https://travis-ci.org/jonschlinkert/arr-union.svg)](https://travis-ci.org/jonschlinkert/arr-union)
> Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
This library is **15-20 times faster** and more performant (scales better) than [array-union](https://github.com/sindresorhus/array-union), which just uses `[].concat.apply([], arguments)`.
## Benchmarks
See the [benchmarks](./benchmark).
```bash
#1: five-arrays.js
array-union.js x 245,487 ops/sec ±0.99% (96 runs sampled)
current.js x 5,267,661 ops/sec ±0.63% (98 runs sampled)
#2: ten-arrays.js
array-union.js x 134,784 ops/sec ±0.51% (94 runs sampled)
current.js x 1,919,143 ops/sec ±0.45% (100 runs sampled)
#3: two-arrays.js
array-union.js x 308,374 ops/sec ±0.75% (96 runs sampled)
current.js x 7,361,915 ops/sec ±0.67% (95 runs sampled)
```
## Install
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i arr-union --save
```
## Usage
```js
var union = require('arr-union');
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
//=> ['a', 'b', 'c', 'd', 'e', 'f']
```
Returns only unique elements:
```js
union(['a', 'a'], ['b', 'c']);
//=> ['a', 'b', 'c']
```
## Other array utilities
* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://github.com/jonschlinkert/arr-diff)
* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
* [arr-filter](https://github.com/jonschlinkert/arr-filter): Faster alternative to javascript's native filter method.
* [arr-map](https://github.com/jonschlinkert/arr-map): Faster, node.js focused alternative to JavaScript's native array map.
* [arr-pluck](https://github.com/jonschlinkert/arr-pluck): Retrieves the value of a specified property from all elements in the collection.
* [arr-reduce](https://github.com/jonschlinkert/arr-reduce): Fast array reduce that also loops over sparse elements.
* [array-unique](https://github.com/jonschlinkert/array-unique): Return an array free of duplicate values. Fastest ES5 implementation.
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-union/issues/new)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 15, 2015._

View File

@@ -1,30 +0,0 @@
/*!
* arr-union <https://github.com/jonschlinkert/arr-union>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
module.exports = function union(arr) {
var len = arguments.length;
var res = [], i = 0;
while (len--) {
var arg = arrayify(arguments[i++]);
for (var j = 0; j < arg.length; j++) {
var ele = arg[j];
if (res.indexOf(ele) === -1) {
res.push(ele);
}
}
}
return res;
};
function arrayify(val) {
return Array.isArray(val) ? val : [val];
}

View File

@@ -1,78 +0,0 @@
{
"_from": "arr-union@^2.0.1",
"_id": "arr-union@2.1.0",
"_inBundle": false,
"_integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=",
"_location": "/gulp-inject/arr-union",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "arr-union@^2.0.1",
"name": "arr-union",
"escapedName": "arr-union",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/gulp-inject/plugin-error"
],
"_resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
"_shasum": "20f9eab5ec70f5c7d215b1077b1c39161d292c7d",
"_spec": "arr-union@^2.0.1",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject/node_modules/plugin-error",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/arr-union/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.",
"devDependencies": {
"array-union": "^1.0.1",
"array-unique": "^0.2.1",
"benchmarked": "^0.1.3",
"chalk": "^1.0.0",
"minimist": "^1.1.1",
"mocha": "^2.2.1",
"should": "^5.2.0",
"verb": "^0.8.6"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/arr-union",
"keywords": [
"add",
"append",
"array",
"arrays",
"combine",
"concat",
"extend",
"union",
"uniq",
"unique",
"util",
"utility",
"utils"
],
"license": "MIT",
"main": "index.js",
"name": "arr-union",
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/arr-union.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.1.0"
}

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014-2015, Jon Schlinkert.
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.

View File

@@ -1,59 +0,0 @@
# extend-shallow [![NPM version](https://badge.fury.io/js/extend-shallow.svg)](http://badge.fury.io/js/extend-shallow) [![Build Status](https://travis-ci.org/jonschlinkert/extend-shallow.svg)](https://travis-ci.org/jonschlinkert/extend-shallow)
> Extend an object with the properties of additional objects. node.js/javascript util.
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i extend-shallow --save
```
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Usage
```js
var extend = require('extend-shallow');
extend({a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
```
Pass an empty object to shallow clone:
```js
var obj = {};
extend(obj, {a: 'b'}, {c: 'd'})
//=> {a: 'b', c: 'd'}
```
## Related
* [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
* [for-own](https://github.com/jonschlinkert/for-own): Iterate over the own enumerable properties of an object, and return an object with properties… [more](https://github.com/jonschlinkert/for-own)
* [for-in](https://github.com/jonschlinkert/for-in): Iterate over the own and inherited enumerable properties of an objecte, and return an object… [more](https://github.com/jonschlinkert/for-in)
* [is-plain-object](https://github.com/jonschlinkert/is-plain-object): Returns true if an object was created by the `Object` constructor.
* [isobject](https://github.com/jonschlinkert/isobject): Returns true if the value is an object and not an array or null.
* [kind-of](https://github.com/jonschlinkert/kind-of): Get the native type of a value.
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 21, 2015._

View File

@@ -1,36 +0,0 @@
'use strict';
var typeOf = require('kind-of');
/**
* Expose `extend`
*/
module.exports = extend;
/**
* Extend `o` with properties of other `objects`.
*
* @param {Object} `o` The target object. Pass an empty object to shallow clone.
* @param {Object} `objects`
* @return {Object}
*/
function extend(o) {
if (typeOf(o) !== 'object') { return {}; }
var args = arguments;
var len = args.length - 1;
for (var i = 0; i < len; i++) {
var obj = args[i + 1];
if (typeOf(obj) === 'object' && typeOf(obj) !== 'regexp') {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
o[key] = obj[key];
}
}
}
}
return o;
};

View File

@@ -1,85 +0,0 @@
{
"_from": "extend-shallow@^1.1.2",
"_id": "extend-shallow@1.1.4",
"_inBundle": false,
"_integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
"_location": "/gulp-inject/extend-shallow",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "extend-shallow@^1.1.2",
"name": "extend-shallow",
"escapedName": "extend-shallow",
"rawSpec": "^1.1.2",
"saveSpec": null,
"fetchSpec": "^1.1.2"
},
"_requiredBy": [
"/gulp-inject/plugin-error"
],
"_resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
"_shasum": "19d6bf94dfc09d76ba711f39b872d21ff4dd9071",
"_spec": "extend-shallow@^1.1.2",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject/node_modules/plugin-error",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/extend-shallow/issues"
},
"bundleDependencies": false,
"dependencies": {
"kind-of": "^1.1.0"
},
"deprecated": false,
"description": "Extend an object with the properties of additional objects. node.js/javascript util.",
"devDependencies": {
"array-slice": "^0.2.2",
"benchmarked": "^0.1.3",
"chalk": "^0.5.1",
"for-own": "^0.1.2",
"glob": "^4.3.1",
"is-plain-object": "^2.0.0",
"minimist": "^1.1.0",
"mocha": "*",
"should": "^5.0.1"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/extend-shallow",
"keywords": [
"extend",
"javascript",
"js",
"keys",
"merge",
"obj",
"object",
"prop",
"properties",
"property",
"props",
"shallow",
"util",
"utility",
"utils",
"value"
],
"license": "MIT",
"main": "index.js",
"name": "extend-shallow",
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/extend-shallow.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.1.4"
}

View File

@@ -1,155 +0,0 @@
# kind-of [![NPM version](https://badge.fury.io/js/kind-of.svg)](http://badge.fury.io/js/kind-of) [![Build Status](https://travis-ci.org/jonschlinkert/kind-of.svg)](https://travis-ci.org/jonschlinkert/kind-of)
> Get the native type of a value.
## Install with [npm](npmjs.org)
```bash
npm i kind-of --save
```
## Usage
```js
var kindOf = require('kind-of');
kindOf(undefined);
//=> 'undefined'
kindOf(null);
//=> 'null'
kindOf(true);
//=> 'boolean'
kindOf(false);
//=> 'boolean'
kindOf(new Boolean(true));
//=> 'boolean'
kindOf(new Buffer(''));
//=> 'buffer'
kindOf(42);
//=> 'number'
kindOf(new Number(42));
//=> 'number'
kindOf("string");
//=> 'string'
kindOf(arguments);
//=> 'arguments'
kindOf({});
//=> 'object'
kindOf(new Test());
//=> 'object'
kindOf(new Date());
//=> 'date'
kindOf([]);
//=> 'array'
kindOf([1, 2, 3]);
//=> 'array'
kindOf(new Array());
//=> 'array'
kindOf(/[\s\S]+/);
//=> 'regexp'
kindOf(new RegExp('^' + 'foo$'));
//=> 'regexp'
kindOf(function () {});
//=> 'function'
kindOf(new Function());
//=> 'function'
```
## Run tests
Install dev dependencies:
```bash
npm i -d && npm test
```
## Benchmarks
Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
```bash
#1: array.js
kind-of x 21,578,944 ops/sec ±1.01% (97 runs sampled)
(lib) type-of x 4,593,840 ops/sec ±0.76% (92 runs sampled)
(lib) typeof x 5,786,776 ops/sec ±0.71% (97 runs sampled)
#2: boolean.js
kind-of x 25,189,600 ops/sec ±0.60% (97 runs sampled)
(lib) type-of x 2,751,076 ops/sec ±0.78% (100 runs sampled)
(lib) typeof x 4,390,312 ops/sec ±0.61% (99 runs sampled)
#3: date.js
kind-of x 8,862,303 ops/sec ±0.77% (99 runs sampled)
(lib) type-of x 6,239,662 ops/sec ±0.67% (94 runs sampled)
(lib) typeof x 6,180,922 ops/sec ±0.59% (97 runs sampled)
#4: function.js
kind-of x 19,685,336 ops/sec ±1.67% (95 runs sampled)
(lib) type-of x 6,648,551 ops/sec ±0.93% (95 runs sampled)
(lib) typeof x 6,631,967 ops/sec ±1.05% (92 runs sampled)
#5: null.js
kind-of x 24,155,010 ops/sec ±0.95% (91 runs sampled)
(lib) type-of x 12,854,583 ops/sec ±0.69% (94 runs sampled)
(lib) typeof x 8,182,952 ops/sec ±0.48% (99 runs sampled)
#6: number.js
kind-of x 20,993,521 ops/sec ±0.37% (98 runs sampled)
(lib) type-of x 2,112,716 ops/sec ±0.73% (96 runs sampled)
(lib) typeof x 4,492,943 ops/sec ±0.68% (96 runs sampled)
#7: object.js
kind-of x 3,686,169 ops/sec ±0.85% (96 runs sampled)
(lib) type-of x 3,661,833 ops/sec ±0.73% (98 runs sampled)
(lib) typeof x 6,159,847 ops/sec ±0.72% (98 runs sampled)
#8: regex.js
kind-of x 10,780,535 ops/sec ±0.75% (95 runs sampled)
(lib) type-of x 5,380,781 ops/sec ±0.83% (92 runs sampled)
(lib) typeof x 5,852,558 ops/sec ±0.67% (95 runs sampled)
#9: string.js
kind-of x 19,713,570 ops/sec ±0.69% (91 runs sampled)
(lib) type-of x 4,017,753 ops/sec ±0.85% (98 runs sampled)
(lib) typeof x 4,370,984 ops/sec ±0.62% (100 runs sampled)
#10: undef.js
kind-of x 23,250,387 ops/sec ±0.88% (91 runs sampled)
(lib) type-of x 13,725,183 ops/sec ±0.62% (91 runs sampled)
(lib) typeof x 20,549,334 ops/sec ±0.74% (97 runs sampled)
```
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license
***
_This file was generated by [verb](https://github.com/assemble/verb) on February 09, 2015._

View File

@@ -1,45 +0,0 @@
var toString = Object.prototype.toString;
/**
* Get the native `typeof` a value.
*
* @param {*} `val`
* @return {*} Native javascript type
*/
module.exports = function kindOf(val) {
if (val === undefined) {
return 'undefined';
}
if (val === null) {
return 'null';
}
if (val === true || val === false || val instanceof Boolean) {
return 'boolean';
}
if (typeof val !== 'object') {
return typeof val;
}
if (Array.isArray(val)) {
return 'array';
}
var type = toString.call(val);
if (val instanceof RegExp || type === '[object RegExp]') {
return 'regexp';
}
if (val instanceof Date || type === '[object Date]') {
return 'date';
}
if (type === '[object Function]') {
return 'function';
}
if (type === '[object Arguments]') {
return 'arguments';
}
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(val)) {
return 'buffer';
}
return type.slice(8, -1).toLowerCase();
};

View File

@@ -1,86 +0,0 @@
{
"_from": "kind-of@^1.1.0",
"_id": "kind-of@1.1.0",
"_inBundle": false,
"_integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
"_location": "/gulp-inject/kind-of",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "kind-of@^1.1.0",
"name": "kind-of",
"escapedName": "kind-of",
"rawSpec": "^1.1.0",
"saveSpec": null,
"fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/gulp-inject/extend-shallow"
],
"_resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"_shasum": "140a3d2d41a36d2efcfa9377b62c24f8495a5c44",
"_spec": "kind-of@^1.1.0",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject/node_modules/extend-shallow",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/kind-of/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Get the native type of a value.",
"devDependencies": {
"benchmarked": "^0.1.3",
"chalk": "^0.5.1",
"glob": "^4.3.5",
"should": "^4.6.1",
"type-of": "^2.0.1",
"typeof": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/kind-of",
"keywords": [
"arguments",
"array",
"boolean",
"check",
"date",
"function",
"is",
"is-type",
"is-type-of",
"kind",
"kind-of",
"number",
"object",
"regexp",
"string",
"test",
"type",
"type-of",
"typeof",
"types"
],
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/kind-of/blob/master/LICENSE"
},
"main": "index.js",
"name": "kind-of",
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/kind-of.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.1.0"
}

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015, Jon Schlinkert.
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.

View File

@@ -1,88 +0,0 @@
# plugin-error [![NPM version](https://badge.fury.io/js/plugin-error.svg)](http://badge.fury.io/js/plugin-error) [![Build Status](https://travis-ci.org/jonschlinkert/plugin-error.svg)](https://travis-ci.org/jonschlinkert/plugin-error)
> Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor changes.
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i plugin-error --save
```
## Usage
```js
var PluginError = require('plugin-error');
```
### new PluginError(pluginName, message[, options]);
**Params**
* `pluginName` should be the module name of your plugin
* `message` **{String|Object}**: may be a string or an existing error object
* `options` **{Object}**
**Behavior:**
* By default the stack will not be shown. Set `options.showStack` to true if you think the stack is important for your error.
* If you pass an error object as the message the stack will be pulled from that, otherwise one will be created.
* If you pass in a custom stack string you need to include the message along with that.
* Error properties will be included in `err.toString()`, but may be omitted by including `{showProperties: false}` in the options.
**Examples**
All of the following are acceptable forms of instantiation:
```javascript
var err = new PluginError('test', {
message: 'something broke'
});
var err = new PluginError({
plugin: 'test',
message: 'something broke'
});
var err = new PluginError('test', 'something broke');
var err = new PluginError('test', 'something broke', {showStack: true});
var existingError = new Error('OMG');
var err = new PluginError('test', existingError, {showStack: true});
```
## Related projects
* [assemble](http://assemble.io): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](http://assemble.io)
* [gulp-util](https://github.com/wearefractal/gulp-util#readme): Utility functions for gulp plugins
* [gulp](http://gulpjs.com): The streaming build system
* [generate](https://github.com/generate/generate): Project generator, for node.js.
* [verb](https://github.com/assemble/verb): Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… [more](https://github.com/assemble/verb)
## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/plugin-error/issues/new)
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 31, 2015._

View File

@@ -1,185 +0,0 @@
/*!
* plugin-error <https://github.com/jonschlinkert/plugin-error>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
var util = require('util');
var red = require('ansi-red');
var cyan = require('ansi-cyan');
var extend = require('extend-shallow');
var differ = require('arr-diff');
var union = require('arr-union');
/**
* Based on gulp-util PluginError (MIT Licensed)
* See: https://github.com/wearefractal/gulp-util
*/
var nonEnum = ['message', 'name', 'stack'];
var ignored = union(nonEnum, ['__safety', '_stack', 'plugin', 'showProperties', 'showStack']);
var props = ['fileName', 'lineNumber', 'message', 'name', 'plugin', 'showProperties', 'showStack', 'stack'];
function PluginError(plugin, message, options) {
if (!(this instanceof PluginError)) {
throw new Error('Call PluginError using new');
}
Error.call(this);
var opts = setDefaults(plugin, message, options);
var self = this;
// if opts has an error, get details from it
if (typeof opts.error === 'object') {
var keys = union(Object.keys(opts.error), nonEnum);
// These properties are not enumerable, so we have to add them explicitly.
keys.forEach(function(prop) {
self[prop] = opts.error[prop];
});
}
// opts object can override
props.forEach(function(prop) {
if (prop in opts) this[prop] = opts[prop];
}, this);
// defaults
if (!this.name) this.name = 'Error';
if (!this.stack) {
/**
* `Error.captureStackTrace` appends a stack property which
* relies on the toString method of the object it is applied to.
*
* Since we are using our own toString method which controls when
* to display the stack trace, if we don't go through this safety
* object we'll get stack overflow problems.
*/
var safety = {};
safety.toString = function() {
return this._messageWithDetails() + '\nStack:';
}.bind(this);
Error.captureStackTrace(safety, arguments.callee || this.constructor);
this.__safety = safety;
}
if (!this.plugin) throw new Error('Missing plugin name');
if (!this.message) throw new Error('Missing error message');
}
util.inherits(PluginError, Error);
/**
* Output a formatted message with details
*/
PluginError.prototype._messageWithDetails = function() {
var msg = 'Message:\n ' + this.message;
var details = this._messageDetails();
if (details !== '') msg += '\n' + details;
return msg;
};
/**
* Output actual message details
*/
PluginError.prototype._messageDetails = function() {
if (!this.showProperties) return '';
var props = differ(Object.keys(this), ignored);
var len = props.length;
if (len === 0) return '';
var res = '', i = 0;
while (len--) {
var prop = props[i++];
res += ' ';
res += prop + ': ' + this[prop];
res += '\n';
}
return 'Details:\n' + res;
};
/**
* Override the `toString` method
*/
PluginError.prototype.toString = function () {
var detailsWithStack = function(stack) {
return this._messageWithDetails() + '\nStack:\n' + stack;
}.bind(this);
var msg = '';
if (this.showStack) {
// if there is no wrapped error, use the stack captured in the PluginError ctor
if (this.__safety) {
msg = this.__safety.stack;
} else if (this._stack) {
msg = detailsWithStack(this._stack);
} else {
// Stack from wrapped error
msg = detailsWithStack(this.stack);
}
return message(msg, this);
}
msg = this._messageWithDetails();
return message(msg, this);
};
// format the output message
function message(msg, thisArg) {
var sig = red(thisArg.name);
sig += ' in plugin ';
sig += '"' + cyan(thisArg.plugin) + '"';
sig += '\n';
sig += msg;
return sig;
}
/**
* Set default options based on arguments.
*/
function setDefaults(plugin, message, opts) {
if (typeof plugin === 'object') {
return defaults(plugin);
}
opts = opts || {};
if (message instanceof Error) {
opts.error = message;
} else if (typeof message === 'object') {
opts = message;
} else {
opts.message = message;
}
opts.plugin = plugin;
return defaults(opts);
}
/**
* Extend default options with:
*
* - `showStack`: default=false
* - `showProperties`: default=true
*
* @param {Object} `opts` Options to extend
* @return {Object}
*/
function defaults(opts) {
return extend({showStack: false, showProperties: true}, opts);
}
/**
* Expose `PluginError`
*/
module.exports = PluginError;

View File

@@ -1,68 +0,0 @@
{
"_from": "plugin-error@^0.1.2",
"_id": "plugin-error@0.1.2",
"_inBundle": false,
"_integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
"_location": "/gulp-inject/plugin-error",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "plugin-error@^0.1.2",
"name": "plugin-error",
"escapedName": "plugin-error",
"rawSpec": "^0.1.2",
"saveSpec": null,
"fetchSpec": "^0.1.2"
},
"_requiredBy": [
"/gulp-inject"
],
"_resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
"_shasum": "3b9bb3335ccf00f425e07437e19276967da47ace",
"_spec": "plugin-error@^0.1.2",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject",
"author": {
"name": "Jon Schlinkert",
"url": "https://github.com/jonschlinkert"
},
"bugs": {
"url": "https://github.com/jonschlinkert/plugin-error/issues"
},
"bundleDependencies": false,
"dependencies": {
"ansi-cyan": "^0.1.1",
"ansi-red": "^0.1.1",
"arr-diff": "^1.0.1",
"arr-union": "^2.0.1",
"extend-shallow": "^1.1.2"
},
"deprecated": false,
"description": "Error handling for vinyl plugins. Just an abstraction of what's in gulp-util with minor changes.",
"devDependencies": {
"mocha": "*",
"should": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/jonschlinkert/plugin-error",
"keywords": [
"error",
"plugin"
],
"license": "MIT",
"main": "index.js",
"name": "plugin-error",
"repository": {
"type": "git",
"url": "git://github.com/jonschlinkert/plugin-error.git"
},
"scripts": {
"test": "mocha"
},
"version": "0.1.2"
}

View File

@@ -1,9 +0,0 @@
# 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.

View File

@@ -1,134 +0,0 @@
# through2
[![NPM](https://nodei.co/npm/through2.png?downloads&downloadRank)](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)`&mdash;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.

View File

@@ -1,66 +0,0 @@
{
"_from": "through2@^2.0.1",
"_id": "through2@2.0.5",
"_inBundle": false,
"_integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"_location": "/gulp-inject/through2",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "through2@^2.0.1",
"name": "through2",
"escapedName": "through2",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/gulp-inject"
],
"_resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
"_shasum": "01c1e39eb31d07cb7d03a96a70823260b23132cd",
"_spec": "through2@^2.0.1",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject",
"author": {
"name": "Rod Vagg",
"email": "r@va.gg",
"url": "https://github.com/rvagg"
},
"bugs": {
"url": "https://github.com/rvagg/through2/issues"
},
"bundleDependencies": false,
"dependencies": {
"readable-stream": "~2.3.6",
"xtend": "~4.0.1"
},
"deprecated": false,
"description": "A tiny wrapper around Node streams2 Transform to avoid explicit subclassing noise",
"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"
},
"homepage": "https://github.com/rvagg/through2#readme",
"keywords": [
"stream",
"streams2",
"through",
"transform"
],
"license": "MIT",
"main": "through2.js",
"name": "through2",
"repository": {
"type": "git",
"url": "git+https://github.com/rvagg/through2.git"
},
"scripts": {
"test": "node test/test.js | faucet"
},
"version": "2.0.5"
}

View File

@@ -1,96 +0,0 @@
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
})

View File

@@ -1,30 +0,0 @@
{
"maxdepth": 4,
"maxstatements": 200,
"maxcomplexity": 12,
"maxlen": 80,
"maxparams": 5,
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": false,
"noarg": true,
"noempty": true,
"nonew": true,
"undef": true,
"unused": "vars",
"trailing": true,
"quotmark": true,
"expr": true,
"asi": true,
"browser": false,
"esnext": true,
"devel": false,
"node": false,
"nonstandard": false,
"predef": ["require", "module", "__dirname", "__filename"]
}

View File

@@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2012-2014 Raynos.
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.

View File

@@ -1,32 +0,0 @@
# xtend
[![browser support][3]][4]
[![locked](http://badges.github.io/stability-badges/dist/locked.svg)](http://github.com/badges/stability-badges)
Extend like a boss
xtend is a basic utility library which allows you to extend an object by appending all of the properties from each object in a list. When there are identical properties, the right-most property takes precedence.
## Examples
```js
var extend = require("xtend")
// extend returns a new object. Does not mutate arguments
var combination = extend({
a: "a",
b: "c"
}, {
b: "b"
})
// { a: "a", b: "b" }
```
## Stability status: Locked
## MIT Licensed
[3]: http://ci.testling.com/Raynos/xtend.png
[4]: http://ci.testling.com/Raynos/xtend

View File

@@ -1,19 +0,0 @@
module.exports = extend
var hasOwnProperty = Object.prototype.hasOwnProperty;
function extend() {
var target = {}
for (var i = 0; i < arguments.length; i++) {
var source = arguments[i]
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
target[key] = source[key]
}
}
}
return target
}

View File

@@ -1,17 +0,0 @@
module.exports = extend
var hasOwnProperty = Object.prototype.hasOwnProperty;
function extend(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i]
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
target[key] = source[key]
}
}
}
return target
}

View File

@@ -1,86 +0,0 @@
{
"_from": "xtend@~4.0.1",
"_id": "xtend@4.0.2",
"_inBundle": false,
"_integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"_location": "/gulp-inject/xtend",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "xtend@~4.0.1",
"name": "xtend",
"escapedName": "xtend",
"rawSpec": "~4.0.1",
"saveSpec": null,
"fetchSpec": "~4.0.1"
},
"_requiredBy": [
"/gulp-inject/through2"
],
"_resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"_shasum": "bb72779f5fa465186b1f438f674fa347fdb5db54",
"_spec": "xtend@~4.0.1",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro/node_modules/gulp-inject/node_modules/through2",
"author": {
"name": "Raynos",
"email": "raynos2@gmail.com"
},
"bugs": {
"url": "https://github.com/Raynos/xtend/issues",
"email": "raynos2@gmail.com"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Jake Verbaten"
},
{
"name": "Matt Esch"
}
],
"dependencies": {},
"deprecated": false,
"description": "extend like a boss",
"devDependencies": {
"tape": "~1.1.0"
},
"engines": {
"node": ">=0.4"
},
"homepage": "https://github.com/Raynos/xtend",
"keywords": [
"extend",
"merge",
"options",
"opts",
"object",
"array"
],
"license": "MIT",
"main": "immutable",
"name": "xtend",
"repository": {
"type": "git",
"url": "git://github.com/Raynos/xtend.git"
},
"scripts": {
"test": "node test"
},
"testling": {
"files": "test.js",
"browsers": [
"ie/7..latest",
"firefox/16..latest",
"firefox/nightly",
"chrome/22..latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest"
]
},
"version": "4.0.2"
}

View File

@@ -1,103 +0,0 @@
var test = require("tape")
var extend = require("./")
var mutableExtend = require("./mutable")
test("merge", function(assert) {
var a = { a: "foo" }
var b = { b: "bar" }
assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
assert.end()
})
test("replace", function(assert) {
var a = { a: "foo" }
var b = { a: "bar" }
assert.deepEqual(extend(a, b), { a: "bar" })
assert.end()
})
test("undefined", function(assert) {
var a = { a: undefined }
var b = { b: "foo" }
assert.deepEqual(extend(a, b), { a: undefined, b: "foo" })
assert.deepEqual(extend(b, a), { a: undefined, b: "foo" })
assert.end()
})
test("handle 0", function(assert) {
var a = { a: "default" }
var b = { a: 0 }
assert.deepEqual(extend(a, b), { a: 0 })
assert.deepEqual(extend(b, a), { a: "default" })
assert.end()
})
test("is immutable", function (assert) {
var record = {}
extend(record, { foo: "bar" })
assert.equal(record.foo, undefined)
assert.end()
})
test("null as argument", function (assert) {
var a = { foo: "bar" }
var b = null
var c = void 0
assert.deepEqual(extend(b, a, c), { foo: "bar" })
assert.end()
})
test("mutable", function (assert) {
var a = { foo: "bar" }
mutableExtend(a, { bar: "baz" })
assert.equal(a.bar, "baz")
assert.end()
})
test("null prototype", function(assert) {
var a = { a: "foo" }
var b = Object.create(null)
b.b = "bar";
assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
assert.end()
})
test("null prototype mutable", function (assert) {
var a = { foo: "bar" }
var b = Object.create(null)
b.bar = "baz";
mutableExtend(a, b)
assert.equal(a.bar, "baz")
assert.end()
})
test("prototype pollution", function (assert) {
var a = {}
var maliciousPayload = '{"__proto__":{"oops":"It works!"}}'
assert.strictEqual(a.oops, undefined)
extend({}, maliciousPayload)
assert.strictEqual(a.oops, undefined)
assert.end()
})
test("prototype pollution mutable", function (assert) {
var a = {}
var maliciousPayload = '{"__proto__":{"oops":"It works!"}}'
assert.strictEqual(a.oops, undefined)
mutableExtend({}, maliciousPayload)
assert.strictEqual(a.oops, undefined)
assert.end()
})

103
node_modules/gulp-inject/package.json generated vendored
View File

@@ -1,103 +0,0 @@
{
"_from": "gulp-inject@^4.3.2",
"_id": "gulp-inject@4.3.2",
"_inBundle": false,
"_integrity": "sha512-dzQgIEVj9vQLwieQ0siRVrgJCisZYrgh/VRvhIS984zJ6OftkjeLfgiENol7bhYM4OlCiyMmxwiYe9mT7hj45A==",
"_location": "/gulp-inject",
"_phantomChildren": {
"ansi-cyan": "0.1.1",
"ansi-red": "0.1.1",
"arr-flatten": "1.1.0",
"array-slice": "0.2.3",
"readable-stream": "2.3.6"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "gulp-inject@^4.3.2",
"name": "gulp-inject",
"escapedName": "gulp-inject",
"rawSpec": "^4.3.2",
"saveSpec": null,
"fetchSpec": "^4.3.2"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/gulp-inject/-/gulp-inject-4.3.2.tgz",
"_shasum": "56525857ec312ce6e75dbb62876bea7e29f10118",
"_spec": "gulp-inject@^4.3.2",
"_where": "/Applications/XAMPP/xamppfiles/htdocs/wordpress/t-latehome/wp-content/plugins/opal-estate-pro",
"author": {
"name": "Joakim Carlstein",
"email": "joakim@klei.se",
"url": "http://joakim.beng.se"
},
"bugs": {
"url": "https://github.com/klei/gulp-inject/issues"
},
"bundleDependencies": false,
"dependencies": {
"ansi-colors": "^1.0.1",
"arrify": "^1.0.1",
"escape-string-regexp": "^1.0.5",
"event-stream": "^3.1.0",
"fancy-log": "^1.3.2",
"group-array": "^0.3.0",
"plugin-error": "^0.1.2",
"stream-to-array": "^2.3.0",
"through2": "^2.0.1"
},
"deprecated": false,
"description": "A javascript, stylesheet and webcomponent injection plugin for Gulp, i.e. inject file references into your index.html",
"devDependencies": {
"@commitlint/cli": "^3.2.0",
"@commitlint/config-angular": "^3.1.1",
"husky": "^0.14.3",
"mocha": "~2.0.1",
"semantic-release": "^12.4.1",
"should": "^4.0.4",
"strip-color": "^0.1.0",
"vinyl": "^2.1.0",
"xo": "^0.13.0"
},
"engines": {
"node": ">=4"
},
"homepage": "https://github.com/klei/gulp-inject",
"keywords": [
"gulpplugin",
"inject",
"stylesheets",
"webcomponents",
"scripts",
"index"
],
"license": "MIT",
"main": "index.js",
"name": "gulp-inject",
"repository": {
"type": "git",
"url": "git+https://github.com/klei/gulp-inject.git"
},
"scripts": {
"commitmsg": "commitlint -e",
"lint": "xo",
"pretest": "npm run -s lint",
"semantic-release": "semantic-release",
"test": "mocha -R spec src/**/*_test.js"
},
"version": "4.3.2",
"xo": {
"space": true,
"envs": [
"node"
],
"rules": {
"object-shorthand": [
2,
"never"
]
}
}
}

View File

@@ -1,7 +0,0 @@
'use strict';
var path = require('path');
module.exports = exports = function extname(file) {
file = file.split('?')[0];
return path.extname(file).slice(1);
};

View File

@@ -1,293 +0,0 @@
'use strict';
var through2 = require('through2');
var fancyLog = require('fancy-log');
var PluginError = require('plugin-error');
var colors = require('ansi-colors');
var streamToArray = require('stream-to-array');
var escapeStringRegexp = require('escape-string-regexp');
var groupArray = require('group-array');
var extname = require('../extname');
var transform = require('../transform');
var tags = require('../tags');
var getFilepath = require('../path');
var magenta = colors.magenta;
var cyan = colors.cyan;
var noop = function noop() {};
/**
* Constants
*/
var PLUGIN_NAME = 'gulp-inject';
var DEFAULT_NAME_FOR_TAGS = 'inject';
var LEADING_WHITESPACE_REGEXP = /^\s*/;
module.exports = exports = function (sources, opt) {
if (!sources) {
throw error('Missing sources stream!');
}
if (!opt) {
opt = {};
}
if (opt.sort) {
throw error('sort option is deprecated! Use `sort-stream` module instead!');
}
if (opt.templateString) {
throw error('`templateString` option is deprecated! Create a virtual `vinyl` file instead!');
}
if (opt.transform && typeof opt.transform !== 'function') {
throw error('transform option must be a function');
}
// Notify people of common mistakes...
if (typeof opt.read !== 'undefined') {
throw error('There is no `read` option. Did you mean to provide it for `gulp.src` perhaps?');
}
// Defaults:
opt.quiet = bool(opt, 'quiet', false);
opt.relative = bool(opt, 'relative', false);
opt.addRootSlash = bool(opt, 'addRootSlash', !opt.relative);
opt.transform = defaults(opt, 'transform', transform);
opt.tags = tags();
opt.name = defaults(opt, 'name', DEFAULT_NAME_FOR_TAGS);
transform.selfClosingTag = bool(opt, 'selfClosingTag', false);
// Is the first parameter a Vinyl File Stream:
if (typeof sources.on === 'function' && typeof sources.pipe === 'function') {
return handleVinylStream(sources, opt);
}
throw error('passing target file as a string is deprecated! Pass a vinyl file stream (i.e. use `gulp.src`)!');
};
function defaults(options, prop, defaultValue) {
return options[prop] || defaultValue;
}
function bool(options, prop, defaultVal) {
return typeof options[prop] === 'undefined' ? defaultVal : Boolean(options[prop]);
}
/**
* Handle injection when files to
* inject comes from a Vinyl File Stream
*
* @param {Stream} sources
* @param {Object} opt
* @returns {Stream}
*/
function handleVinylStream(sources, opt) {
var collected = streamToArray(sources);
return through2.obj(function (target, enc, cb) {
if (target.isStream()) {
return cb(error('Streams not supported for target templates!'));
}
collected.then(function (collection) {
target.contents = getNewContent(target, collection, opt);
this.push(target);
cb();
}.bind(this))
.catch(function (err) {
cb(err);
});
});
}
/**
* Get new content for template
* with all injections made
*
* @param {Object} target
* @param {Array} collection
* @param {Object} opt
* @returns {Buffer}
*/
function getNewContent(target, collection, opt) {
var logger = opt.quiet ? noop : function (filesCount) {
if (filesCount) {
var pluralState = filesCount > 1 ? 's' : '';
log(cyan(filesCount) + ' file' + pluralState + ' into ' + magenta(target.relative) + '.');
} else {
log('Nothing to inject into ' + magenta(target.relative) + '.');
}
};
var content = String(target.contents);
var targetExt = extname(target.path);
var files = prepareFiles(collection, targetExt, opt, target);
var filesPerTags = groupArray(files, 'tagKey');
var startAndEndTags = Object.keys(filesPerTags);
var matches = [];
var injectedFilesCount = 0;
startAndEndTags.forEach(function (tagKey) {
var files = filesPerTags[tagKey];
var startTag = files[0].startTag;
var endTag = files[0].endTag;
var tagsToInject = getTagsToInject(files, target, opt);
content = inject(content, {
startTag: startTag,
endTag: endTag,
tagsToInject: tagsToInject,
removeTags: opt.removeTags,
empty: opt.empty,
willInject: function (filesToInject) {
injectedFilesCount += filesToInject.length;
},
onMatch: function (match) {
matches.push(match[0]);
}
});
});
logger(injectedFilesCount);
if (opt.empty) {
var ext = '{{ANY}}';
var startTag = getTagRegExp(opt.tags.start(targetExt, ext, opt.starttag), ext, opt);
var endTag = getTagRegExp(opt.tags.end(targetExt, ext, opt.endtag), ext, opt);
content = inject(content, {
startTag: startTag,
endTag: endTag,
tagsToInject: [],
removeTags: opt.removeTags,
empty: opt.empty,
shouldAbort: function (match) {
return matches.indexOf(match[0]) !== -1;
}
});
}
return new Buffer(content);
}
/**
* Inject tags into content for given
* start and end tags
*
* @param {String} content
* @param {Object} opt
* @returns {String}
*/
function inject(content, opt) {
var startTag = opt.startTag;
var endTag = opt.endTag;
var startMatch;
var endMatch;
/**
* The content consists of:
*
* <everything before startMatch>
* <startMatch>
* <previousInnerContent>
* <endMatch>
* <everything after endMatch>
*/
while ((startMatch = startTag.exec(content)) !== null) {
if (typeof opt.onMatch === 'function') {
opt.onMatch(startMatch);
}
if (typeof opt.shouldAbort === 'function' && opt.shouldAbort(startMatch)) {
continue;
}
// Take care of content length change:
endTag.lastIndex = startTag.lastIndex;
endMatch = endTag.exec(content);
if (!endMatch) {
throw error('Missing end tag for start tag: ' + startMatch[0]);
}
var toInject = opt.tagsToInject.slice();
if (typeof opt.willInject === 'function') {
opt.willInject(toInject);
}
// <everything before startMatch>:
var newContents = content.slice(0, startMatch.index);
if (opt.removeTags) {
if (opt.empty) {
// Take care of content length change:
startTag.lastIndex -= startMatch[0].length;
}
} else {
// <startMatch> + <endMatch>
toInject.unshift(startMatch[0]);
toInject.push(endMatch[0]);
}
var previousInnerContent = content.substring(startTag.lastIndex, endMatch.index);
var indent = getLeadingWhitespace(previousInnerContent);
// <new inner content>:
newContents += toInject.join(indent);
// <everything after endMatch>:
newContents += content.slice(endTag.lastIndex);
// replace old content with new:
content = newContents;
}
return content;
}
function getLeadingWhitespace(str) {
return str.match(LEADING_WHITESPACE_REGEXP)[0];
}
function prepareFiles(files, targetExt, opt, target) {
return files.map(function (file) {
var ext = extname(file.path);
var filePath = getFilepath(file, target, opt);
var startTag = getTagRegExp(opt.tags.start(targetExt, ext, opt.starttag), ext, opt, filePath);
var endTag = getTagRegExp(opt.tags.end(targetExt, ext, opt.endtag), ext, opt, filePath);
var tagKey = String(startTag) + String(endTag);
return {
file: file,
ext: ext,
startTag: startTag,
endTag: endTag,
tagKey: tagKey
};
});
}
function getTagRegExp(tag, sourceExt, opt, sourcePath) {
tag = makeWhiteSpaceOptional(escapeStringRegexp(tag));
tag = replaceVariables(tag, {
name: opt.name,
path: sourcePath,
ext: sourceExt === '{{ANY}}' ? '.+' : sourceExt
});
return new RegExp(tag, 'ig');
}
function replaceVariables(str, variables) {
return Object.keys(variables).reduce(function (str, variable) {
return str.replace(new RegExp(escapeStringRegexp(escapeStringRegexp('{{' + variable + '}}')), 'ig'), variables[variable] + '\\b');
}, str);
}
function makeWhiteSpaceOptional(str) {
return str.replace(/\s+/g, '\\s*');
}
function getTagsToInject(files, target, opt) {
return files.reduce(function transformFile(lines, file, i, files) {
var filepath = getFilepath(file.file, target, opt);
var transformedContents = opt.transform(filepath, file.file, i, files.length, target);
if (typeof transformedContents !== 'string') {
return lines;
}
return lines.concat(transformedContents);
}, []);
}
function log(message) {
fancyLog.info(magenta(PLUGIN_NAME), message);
}
function error(message) {
return new PluginError(PLUGIN_NAME, message);
}

View File

@@ -1,62 +0,0 @@
'use strict';
var path = require('path');
var arrify = require('arrify');
module.exports = exports = function getFilepath(sourceFile, targetFile, opt) {
opt = opt || {};
var ignorePath = arrify(opt.ignorePath);
var base = opt.relative ? path.dirname(addRootSlash(unixify(targetFile.path))) : addRootSlash(unixify(sourceFile.cwd));
var filepath = unixify(path.relative(base, addRootSlash(unixify(sourceFile.path))));
if (ignorePath.length) {
filepath = removeBasePath(ignorePath, filepath);
}
if (opt.addPrefix) {
filepath = addPrefix(filepath, opt.addPrefix);
}
if (opt.addRootSlash) {
filepath = addRootSlash(filepath);
} else if (!opt.addPrefix) {
filepath = removeRootSlash(filepath);
}
if (opt.addSuffix) {
filepath = addSuffix(filepath, opt.addSuffix);
}
return filepath;
};
function unixify(filepath) {
return filepath.replace(/\\/g, '/');
}
function addRootSlash(filepath) {
return filepath.replace(/^\/*([^\/])/, '/$1');
}
function removeRootSlash(filepath) {
return filepath.replace(/^\/+/, '');
}
function addPrefix(filepath, prefix) {
return prefix + addRootSlash(filepath);
}
function addSuffix(filepath, suffix) {
return filepath + suffix;
}
function removeBasePath(basedirs, filepath) {
return basedirs.map(unixify).reduce(function (path, remove) {
if (path[0] === '/' && remove[0] !== '/') {
remove = '/' + remove;
}
if (path[0] !== '/' && remove[0] === '/') {
path = '/' + path;
}
if (remove && path.indexOf(remove) === 0) {
return path.slice(remove.length);
}
return path;
}, filepath);
}

View File

@@ -1,184 +0,0 @@
/* eslint-env mocha */
'use strict';
var path = require('path');
var Vinyl = require('vinyl');
require('should');
var getFilepath = require('./');
describe('getFilepath', function () {
describe('(relative=false)', function () {
it('returns the path relative to the source file\'s cwd', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source);
filepath.should.equal('dir/file.js');
});
it('returns the unixified path relative to the source file\'s cwd', function () {
var source = new Vinyl({
cwd: 'C:\\a\\folder',
path: 'C:\\a\\folder\\dir\\file.js',
base: 'C:\\a\\folder\\dir'
});
var filepath = getFilepath(source);
filepath.should.equal('dir/file.js');
});
});
describe('(relative=true)', function () {
it('returns the path relative to the target file\'s directory', function () {
var target = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir1', 'index.html'),
base: path.join(__dirname, 'dir1')
});
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir2', 'file.js'),
base: path.join(__dirname, 'dir2')
});
var filepath = getFilepath(source, target, {relative: true});
filepath.should.equal('../dir2/file.js');
});
it('returns the unixified path relative to the source file\'s cwd', function () {
var target = new Vinyl({
cwd: 'C:\\a\\folder',
path: 'C:\\a\\folder\\dir1\\index.html',
base: 'C:\\a\\folder\\dir1'
});
var source = new Vinyl({
cwd: 'C:\\a\\folder',
path: 'C:\\a\\folder\\dir2\\file.js',
base: 'C:\\a\\folder\\dir2'
});
var filepath = getFilepath(source, target, {relative: true});
filepath.should.equal('../dir2/file.js');
});
});
describe('(ignorePath)', function () {
it('removes the provided `ignorePath` from the beginning of the path', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {ignorePath: 'dir'});
filepath.should.equal('file.js');
});
it('removes the provided `ignorePath` even if it both begins and ends in a `/` from the beginning of the path', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {ignorePath: '/dir/'});
filepath.should.equal('file.js');
});
it('removes the provided `ignorePath`s from the beginning of the path', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {ignorePath: ['dir', 'dir2']});
filepath.should.equal('file.js');
});
it('removes the provided `ignorePath` unixified from the beginning of the path', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'deep', 'file.js'),
base: path.join(__dirname, 'dir', 'deep')
});
var filepath = getFilepath(source, null, {ignorePath: ['\\dir\\deep']});
filepath.should.equal('file.js');
});
it('removes the provided `ignorePath` unixified from the beginning of a unixified path', function () {
var source = new Vinyl({
cwd: 'C:\\a\\folder',
path: 'C:\\a\\folder\\dir\\deep\\file.js',
base: 'C:\\a\\folder\\dir\\deep'
});
var filepath = getFilepath(source, null, {ignorePath: ['\\dir\\deep']});
filepath.should.equal('file.js');
});
it('removes the provided `ignorePath` from the beginning of a unixified path', function () {
var source = new Vinyl({
cwd: 'C:\\a\\folder',
path: 'C:\\a\\folder\\dir\\deep\\file.js',
base: 'C:\\a\\folder\\dir\\deep'
});
var filepath = getFilepath(source, null, {ignorePath: ['dir/deep']});
filepath.should.equal('file.js');
});
});
describe('(addRootSlash=true)', function () {
it('prepends the path with a `/`', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {addRootSlash: true});
filepath.should.equal('/dir/file.js');
});
});
describe('(addPrefix)', function () {
it('prepends the prefix and a `/` to the path', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {addPrefix: 'hello'});
filepath.should.equal('hello/dir/file.js');
});
it('keeps any leading `/` from the prefix', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {addPrefix: '/hello'});
filepath.should.equal('/hello/dir/file.js');
});
});
describe('(addSuffix)', function () {
it('appends the suffix to the path', function () {
var source = new Vinyl({
cwd: __dirname,
path: path.join(__dirname, 'dir', 'file.js'),
base: path.join(__dirname, 'dir')
});
var filepath = getFilepath(source, null, {addSuffix: '?hello'});
filepath.should.equal('dir/file.js?hello');
});
});
});

View File

@@ -1,48 +0,0 @@
/**
* Constants
*/
var DEFAULT_TARGET = 'html';
var DEFAULTS = {
STARTS: {
html: '<!-- {{name}}:{{ext}} -->',
jsx: '{/* {{name}}:{{ext}} */}',
jade: '//- {{name}}:{{ext}}',
pug: '//- {{name}}:{{ext}}',
slm: '/ {{name}}:{{ext}}',
slim: '/ {{name}}:{{ext}}',
haml: '-# {{name}}:{{ext}}',
less: '/* {{name}}:{{ext}} */',
sass: '/* {{name}}:{{ext}} */',
scss: '/* {{name}}:{{ext}} */'
},
ENDS: {
html: '<!-- endinject -->',
jsx: '{/* endinject */}',
jade: '//- endinject',
pug: '//- endinject',
slm: '/ endinject',
slim: '/ endinject',
haml: '-# endinject',
less: '/* endinject */',
sass: '/* endinject */',
scss: '/* endinject */'
}
};
module.exports = function tags() {
return {
start: getTag.bind(null, DEFAULTS.STARTS),
end: getTag.bind(null, DEFAULTS.ENDS)
};
};
function getTag(defaults, targetExt, sourceExt, defaultValue) {
var tag = defaultValue;
if (!tag) {
tag = defaults[targetExt] || defaults[DEFAULT_TARGET];
} else if (typeof tag === 'function') {
tag = tag(targetExt, sourceExt);
}
return tag;
}

View File

@@ -1,240 +0,0 @@
'use strict';
var extname = require('../extname');
/**
* Constants
*/
var TARGET_TYPES = ['html', 'jade', 'pug', 'slm', 'slim', 'jsx', 'haml', 'less', 'sass', 'scss', 'twig'];
var IMAGES = ['jpeg', 'jpg', 'png', 'gif'];
var DEFAULT_TARGET = TARGET_TYPES[0];
/**
* Transform module
*/
var transform = module.exports = exports = function (filepath, i, length, sourceFile, targetFile) {
var type;
if (targetFile && targetFile.path) {
var ext = extname(targetFile.path);
type = typeFromExt(ext);
}
if (!isTargetType(type)) {
type = DEFAULT_TARGET;
}
var func = transform[type];
if (func) {
return func.apply(transform, arguments);
}
};
/**
* Options
*/
transform.selfClosingTag = false;
/**
* Transform functions
*/
TARGET_TYPES.forEach(function (targetType) {
transform[targetType] = function (filepath) {
var ext = extname(filepath);
var type = typeFromExt(ext);
var func = transform[targetType][type];
if (func) {
return func.apply(transform[targetType], arguments);
}
};
});
transform.html.css = function (filepath) {
return '<link rel="stylesheet" href="' + filepath + '"' + end();
};
transform.html.js = function (filepath) {
return '<script src="' + filepath + '"></script>';
};
transform.html.map = transform.html.js;
transform.html.jsx = function (filepath) {
return '<script type="text/jsx" src="' + filepath + '"></script>';
};
transform.html.html = function (filepath) {
return '<link rel="import" href="' + filepath + '"' + end();
};
transform.html.coffee = function (filepath) {
return '<script type="text/coffeescript" src="' + filepath + '"></script>';
};
transform.html.image = function (filepath) {
return '<img src="' + filepath + '"' + end();
};
transform.jade.css = function (filepath) {
return 'link(rel="stylesheet", href="' + filepath + '")';
};
transform.jade.js = function (filepath) {
return 'script(src="' + filepath + '")';
};
transform.jade.jsx = function (filepath) {
return 'script(type="text/jsx", src="' + filepath + '")';
};
transform.jade.jade = function (filepath) {
return 'include ' + filepath;
};
transform.jade.html = function (filepath) {
return 'link(rel="import", href="' + filepath + '")';
};
transform.jade.coffee = function (filepath) {
return 'script(type="text/coffeescript", src="' + filepath + '")';
};
transform.jade.image = function (filepath) {
return 'img(src="' + filepath + '")';
};
transform.pug.css = function (filepath) {
return 'link(rel="stylesheet", href="' + filepath + '")';
};
transform.pug.js = function (filepath) {
return 'script(src="' + filepath + '")';
};
transform.pug.jsx = function (filepath) {
return 'script(type="text/jsx", src="' + filepath + '")';
};
transform.pug.pug = function (filepath) {
return 'include ' + filepath;
};
transform.pug.html = function (filepath) {
return 'link(rel="import", href="' + filepath + '")';
};
transform.pug.coffee = function (filepath) {
return 'script(type="text/coffeescript", src="' + filepath + '")';
};
transform.pug.image = function (filepath) {
return 'img(src="' + filepath + '")';
};
transform.slm.css = function (filepath) {
return 'link rel="stylesheet" href="' + filepath + '"';
};
transform.slm.js = function (filepath) {
return 'script src="' + filepath + '"';
};
transform.slm.html = function (filepath) {
return 'link rel="import" href="' + filepath + '"';
};
transform.slm.coffee = function (filepath) {
return 'script type="text/coffeescript" src="' + filepath + '"';
};
transform.slm.image = function (filepath) {
return 'img src="' + filepath + '"';
};
transform.slim.css = transform.slm.css;
transform.slim.js = transform.slm.js;
transform.slim.html = transform.slm.html;
transform.slim.coffee = transform.slm.coffee;
transform.slim.image = transform.slm.image;
transform.haml.css = function (filepath) {
return '%link{rel:"stylesheet", href:"' + filepath + '"}';
};
transform.haml.js = function (filepath) {
return '%script{src:"' + filepath + '"}';
};
transform.haml.html = function (filepath) {
return '%link{rel:"import", href:"' + filepath + '"}';
};
transform.haml.coffee = function (filepath) {
return '%script{type:"text/coffeescript", src:"' + filepath + '"}';
};
transform.haml.image = function (filepath) {
return '%img{src:"' + filepath + '"}';
};
transform.less.less = function (filepath) {
return '@import "' + filepath + '";';
};
transform.less.css = transform.less.less;
transform.sass.sass = function (filepath) {
return '@import "' + filepath + '"';
};
transform.sass.scss = transform.sass.sass;
transform.sass.css = transform.sass.sass;
transform.scss.sass = transform.less.less;
transform.scss.scss = transform.scss.sass;
transform.scss.css = transform.scss.sass;
transform.twig.css = function (filepath) {
return '<link rel="stylesheet" href="{{ asset("' + filepath + '") }}"' + end();
};
transform.twig.js = function (filepath) {
return '<script src="{{ asset("' + filepath + '") }}"></script>';
};
/**
* Transformations for jsx is like html
* but always with self closing tags, invalid jsx otherwise
*/
Object.keys(transform.html).forEach(function (type) {
transform.jsx[type] = function () {
var originalOption = transform.selfClosingTag;
transform.selfClosingTag = true;
var result = transform.html[type].apply(transform.html, arguments);
transform.selfClosingTag = originalOption;
return result;
};
});
function end() {
return transform.selfClosingTag ? ' />' : '>';
}
function typeFromExt(ext) {
ext = ext.toLowerCase();
if (isImage(ext)) {
return 'image';
}
return ext;
}
function isImage(ext) {
return IMAGES.indexOf(ext) > -1;
}
function isTargetType(type) {
if (!type) {
return false;
}
return TARGET_TYPES.indexOf(type) > -1;
}