initial commit
This commit is contained in:
20
node_modules/gulp-replace/LICENSE
generated
vendored
Normal file
20
node_modules/gulp-replace/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Larry Davis
|
||||
|
||||
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.
|
||||
136
node_modules/gulp-replace/README.md
generated
vendored
Normal file
136
node_modules/gulp-replace/README.md
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
# gulp-replace [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url]
|
||||
> A string replace plugin for gulp 3
|
||||
|
||||
## Usage
|
||||
|
||||
First, install `gulp-replace` as a development dependency:
|
||||
|
||||
```shell
|
||||
npm install --save-dev gulp-replace
|
||||
```
|
||||
|
||||
Then, add it to your `gulpfile.js`:
|
||||
|
||||
### Simple string replace
|
||||
```javascript
|
||||
var replace = require('gulp-replace');
|
||||
|
||||
gulp.task('templates', function(){
|
||||
gulp.src(['file.txt'])
|
||||
.pipe(replace('bar', 'foo'))
|
||||
.pipe(gulp.dest('build/'));
|
||||
});
|
||||
```
|
||||
|
||||
### Simple regex replace
|
||||
```javascript
|
||||
var replace = require('gulp-replace');
|
||||
|
||||
gulp.task('templates', function(){
|
||||
gulp.src(['file.txt'])
|
||||
// See http://mdn.io/string.replace#Specifying_a_string_as_a_parameter
|
||||
.pipe(replace(/foo(.{3})/g, '$1foo'))
|
||||
.pipe(gulp.dest('build/'));
|
||||
});
|
||||
```
|
||||
|
||||
### String replace with function callback
|
||||
```javascript
|
||||
var replace = require('gulp-replace');
|
||||
|
||||
gulp.task('templates', function(){
|
||||
gulp.src(['file.txt'])
|
||||
.pipe(replace('foo', function(match) {
|
||||
// Replaces instances of "foo" with "oof"
|
||||
return match.reverse();
|
||||
}))
|
||||
.pipe(gulp.dest('build/'));
|
||||
});
|
||||
```
|
||||
|
||||
### Regex replace with function callback
|
||||
```javascript
|
||||
var replace = require('gulp-replace');
|
||||
|
||||
gulp.task('templates', function(){
|
||||
gulp.src(['file.txt'])
|
||||
.pipe(replace(/foo(.{3})/g, function(match, p1, offset, string) {
|
||||
// Replace foobaz with barbaz and log a ton of information
|
||||
// See http://mdn.io/string.replace#Specifying_a_function_as_a_parameter
|
||||
console.log('Found ' + match + ' with param ' + p1 + ' at ' + offset + ' inside of ' + string);
|
||||
return 'bar' + p1;
|
||||
}))
|
||||
.pipe(gulp.dest('build/'));
|
||||
});
|
||||
```
|
||||
|
||||
### Function callback with file object
|
||||
```javascript
|
||||
var replace = require('gulp-replace');
|
||||
|
||||
gulp.task('templates', function(){
|
||||
gulp.src(['file.txt'])
|
||||
.pipe(replace('filename', function() {
|
||||
// Replaces instances of "filename" with "file.txt"
|
||||
// this.file is also available for regex replace
|
||||
// See https://github.com/gulpjs/vinyl#instance-properties for details on available properties
|
||||
return this.file.relative;
|
||||
}))
|
||||
.pipe(gulp.dest('build/'));
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
gulp-replace can be called with a string or regex.
|
||||
|
||||
### replace(string, replacement[, options])
|
||||
|
||||
#### string
|
||||
Type: `String`
|
||||
|
||||
The string to search for.
|
||||
|
||||
#### replacement
|
||||
Type: `String` or `Function`
|
||||
|
||||
The replacement string or function. If `replacement` is a function, it will be called once for each match and will be passed the string that is to be replaced.
|
||||
|
||||
The value of `this.file` will be equal to the [vinyl instance](https://github.com/gulpjs/vinyl#instance-properties) for the file being processed.
|
||||
|
||||
### replace(regex, replacement[, options])
|
||||
|
||||
#### regex
|
||||
Type: `RegExp`
|
||||
|
||||
The regex pattern to search for. See the [MDN documentation for RegExp] for details.
|
||||
|
||||
#### replacement
|
||||
Type: `String` or `Function`
|
||||
|
||||
The replacement string or function. See the [MDN documentation for String.replace] for details on special replacement string patterns and arguments to the replacement function.
|
||||
|
||||
The value of `this.file` will be equal to the [vinyl instance](https://github.com/gulpjs/vinyl#instance-properties) for the file being processed.
|
||||
|
||||
### gulp-replace options
|
||||
|
||||
An optional third argument, `options`, can be passed.
|
||||
|
||||
#### options
|
||||
Type: `Object`
|
||||
|
||||
##### options.skipBinary
|
||||
Type: `boolean`
|
||||
Default: `true`
|
||||
|
||||
Skip binary files. This option is true by default. If you want to replace content in binary files, you must explicitly set it to false
|
||||
|
||||
|
||||
[MDN documentation for RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
||||
[MDN documentation for String.replace]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
|
||||
|
||||
[travis-url]: http://travis-ci.org/lazd/gulp-replace
|
||||
[travis-image]: https://secure.travis-ci.org/lazd/gulp-replace.svg?branch=master
|
||||
[npm-url]: https://npmjs.org/package/gulp-replace
|
||||
[npm-image]: https://badge.fury.io/js/gulp-replace.svg
|
||||
91
node_modules/gulp-replace/index.js
generated
vendored
Normal file
91
node_modules/gulp-replace/index.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
var Transform = require('readable-stream/transform');
|
||||
var rs = require('replacestream');
|
||||
var istextorbinary = require('istextorbinary');
|
||||
|
||||
module.exports = function(search, _replacement, options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (options.skipBinary === undefined) {
|
||||
options.skipBinary = true;
|
||||
}
|
||||
|
||||
return new Transform({
|
||||
objectMode: true,
|
||||
transform: function(file, enc, callback) {
|
||||
if (file.isNull()) {
|
||||
return callback(null, file);
|
||||
}
|
||||
|
||||
var replacement = _replacement;
|
||||
if (typeof _replacement === 'function') {
|
||||
// Pass the vinyl file object as this.file
|
||||
replacement = _replacement.bind({ file: file });
|
||||
}
|
||||
|
||||
function doReplace() {
|
||||
if (file.isStream()) {
|
||||
file.contents = file.contents.pipe(rs(search, replacement));
|
||||
return callback(null, file);
|
||||
}
|
||||
|
||||
if (file.isBuffer()) {
|
||||
if (search instanceof RegExp) {
|
||||
file.contents = new Buffer(String(file.contents).replace(search, replacement));
|
||||
}
|
||||
else {
|
||||
var chunks = String(file.contents).split(search);
|
||||
|
||||
var result;
|
||||
if (typeof replacement === 'function') {
|
||||
// Start with the first chunk already in the result
|
||||
// Replacements will be added thereafter
|
||||
// This is done to avoid checking the value of i in the loop
|
||||
result = [ chunks[0] ];
|
||||
|
||||
// The replacement function should be called once for each match
|
||||
for (var i = 1; i < chunks.length; i++) {
|
||||
// Add the replacement value
|
||||
result.push(replacement(search));
|
||||
|
||||
// Add the next chunk
|
||||
result.push(chunks[i]);
|
||||
}
|
||||
|
||||
result = result.join('');
|
||||
}
|
||||
else {
|
||||
result = chunks.join(replacement);
|
||||
}
|
||||
|
||||
file.contents = new Buffer(result);
|
||||
}
|
||||
return callback(null, file);
|
||||
}
|
||||
|
||||
callback(null, file);
|
||||
}
|
||||
|
||||
if (options && options.skipBinary) {
|
||||
istextorbinary.isText(file.path, file.contents, function(err, result) {
|
||||
if (err) {
|
||||
return callback(err, file);
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
callback(null, file);
|
||||
} else {
|
||||
doReplace();
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
doReplace();
|
||||
}
|
||||
});
|
||||
};
|
||||
65
node_modules/gulp-replace/package.json
generated
vendored
Normal file
65
node_modules/gulp-replace/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"_from": "gulp-replace",
|
||||
"_id": "gulp-replace@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-lgdmrFSI1SdhNMXZQbrC75MOl1UjYWlOWNbNRnz+F/KHmgxt3l6XstBoAYIdadwETFyG/6i+vWUSCawdC3pqOw==",
|
||||
"_location": "/gulp-replace",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "gulp-replace",
|
||||
"name": "gulp-replace",
|
||||
"escapedName": "gulp-replace",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/",
|
||||
"#USER"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.0.0.tgz",
|
||||
"_shasum": "b32bd61654d97b8d78430a67b3e8ce067b7c9143",
|
||||
"_spec": "gulp-replace",
|
||||
"_where": "D:\\Air66 Files\\dev_sites\\www.airurl.dev.cc\\user\\plugins\\air66Theme",
|
||||
"author": {
|
||||
"name": "Larry Davis",
|
||||
"email": "lazdnet@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/lazd/gulp-replace/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"istextorbinary": "2.2.1",
|
||||
"readable-stream": "^2.0.1",
|
||||
"replacestream": "^4.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A string replace plugin for gulp",
|
||||
"devDependencies": {
|
||||
"concat-stream": "^1.5.2",
|
||||
"mocha": "^5.1.1",
|
||||
"should": "^13.2.1",
|
||||
"vinyl": "^2.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
},
|
||||
"homepage": "https://github.com/lazd/gulp-replace#readme",
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"replace"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "gulp-replace",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/lazd/gulp-replace.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
Reference in New Issue
Block a user