gulp-ext-replace
Advanced tools
Comparing version 0.0.5 to 0.1.0
'use strict'; | ||
var gutil = require('gulp-util'), | ||
through = require('through2'); | ||
var gutil = require('gulp-util'); | ||
var through = require('through2'); | ||
@@ -11,3 +11,3 @@ module.exports = function(ext) { | ||
} else { | ||
file.path = file.path.replace(/\.[a-z]+$/g, ext); | ||
file.path = file.path.replace(/\.\w+$/gi, ext); | ||
} | ||
@@ -19,2 +19,2 @@ | ||
return through.obj(extension_replace); | ||
}; | ||
}; |
{ | ||
"name": "gulp-ext-replace", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/tjeastmond/gulp-ext-replace", | ||
@@ -20,3 +20,2 @@ "description": "Small gulp plugin to change a file's extension", | ||
"keywords": [ | ||
"gulpplugin", | ||
"extension", | ||
@@ -37,2 +36,2 @@ "file", | ||
} | ||
} | ||
} |
@@ -5,2 +5,6 @@ # gulp-ext-replace | ||
### Update | ||
I removed the `gulpplugin` keyword from the package file so that this plugin doesn't show up on the Gulp website. While I'd prefer to continue using this plugin, the very awesome `gulp-replace` plugin is likely a better choice for you. | ||
## Install | ||
@@ -41,2 +45,2 @@ | ||
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. | ||
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. |
@@ -1,5 +0,5 @@ | ||
var gulp = require('gulp'), | ||
gutil = require('gulp-util'), | ||
replace = require('../index'), | ||
should = require('should'); | ||
var gulp = require('gulp'); | ||
var gutil = require('gulp-util'); | ||
var replace = require('../index'); | ||
var should = require('should'); | ||
@@ -15,50 +15,38 @@ var fakeFile = function(filename) { | ||
describe('gulp-file-extension', function() { | ||
it('should change the extension', function(done) { | ||
var stream = replace('.scss'), | ||
file = fakeFile('styles.css'); | ||
var testChange = function(options, done) { | ||
var stream = replace(options.newExt); | ||
var file = fakeFile(options.filename); | ||
stream.on('error', done); | ||
stream.on('error', done); | ||
stream.on('data', function(file) { | ||
should.exist(file); | ||
file.path.should.equal('fixtures/styles.scss'); | ||
file.relative.should.equal('styles.scss'); | ||
done(); | ||
}); | ||
stream.on('data', function(file) { | ||
should.exist(file); | ||
file.path.should.equal('fixtures/' + options.newFilename); | ||
file.relative.should.equal(options.newFilename); | ||
done(); | ||
}); | ||
stream.write(file); | ||
stream.write(file); | ||
}; | ||
describe('gulp-file-extension', function() { | ||
it('should change the extension', function(done) { | ||
var options = { filename: 'styles.scss', newFilename: 'styles.css', newExt: '.css'}; | ||
testChange(options, done); | ||
}); | ||
it('should change the tricky extension', function(done) { | ||
var stream = replace('.scss'), | ||
file = fakeFile('styles.min.css'); | ||
stream.on('error', done); | ||
stream.on('data', function(file) { | ||
should.exist(file); | ||
file.path.should.equal('fixtures/styles.min.scss'); | ||
file.relative.should.equal('styles.min.scss'); | ||
done(); | ||
}); | ||
stream.write(file); | ||
var options = { filename: 'styles.min.css', newFilename: 'styles.min.scss', newExt: '.scss'}; | ||
testChange(options, done); | ||
}); | ||
it('should not change the extension', function(done) { | ||
var stream = replace('.css'), | ||
file = fakeFile('styles.css'); | ||
var options = { filename: 'styles.css', newFilename: 'styles.css', newExt: '.css'}; | ||
testChange(options, done); | ||
}); | ||
stream.on('error', done); | ||
stream.on('data', function(file) { | ||
should.exist(file); | ||
file.path.should.equal('fixtures/styles.css'); | ||
file.relative.should.equal('styles.css'); | ||
done(); | ||
}); | ||
stream.write(file); | ||
it('should work with numbers too', function(done) { | ||
var options = { filename: 'styles.mp4', newFilename: 'styles.mp3', newExt: '.mp3'}; | ||
testChange(options, done); | ||
}); | ||
}); | ||
}); |
4583
45
56