Git Product home page Git Product logo

gulp-ext-replace's Introduction

Hi there ๐Ÿ‘‹

gulp-ext-replace's People

Contributors

nickbolles avatar sebs avatar tjeastmond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gulp-ext-replace's Issues

Replaced in the wrong place

source path "bower_components\video.js\dist\video.js"
.pipe(extReplace('.min.js'))
result path "bower_components*video.min.js*\dist\video.js"

replaced in the wrong place

Copying files with new extension, not replacing the extension

The following code is copying .css files as .css.hidden (not renaming)

gulp.task('hide-material-css-files', function () {
    var ext_replace = require('gulp-ext-replace');

    console.log(ext_replace);

    return gulp.src(material + '/**/*.css')
               .pipe(ext_replace('.css.hidden'))
               .pipe(gulp.dest(material));
});

is there a way to get the function to rename instead of copying?

Rename files which have multiple extension type such as *.haml.html to *.html

Hello

I'm using rails style file format. So, it's look like index.haml.html
Would be a nice to have option for working with files which have multiple types.

Example:
Origin file index.haml.html or index.htmlor index.haml.something.html โ†’ index.html

Can i send a pull request for this missing feature?

Replace to no extension

I have this use pattern:

- templates
  - t1.js.jst
  - t2.html.jst
  - t3.stuf.zbuf.jst

Then gulp:

    gulp.src('templates/**/*.jst')
      .pipe(extReplace(''))
      .pipe(gulp.dest('output'));

And it does not produce the expected result:

- templates
  - t1.js
  - t2.html
  - t3.stuf.zbuf

The extension still remain, using 0.2.0

A dot in a folder name

If there's a dot in a source folder name, the plugin creates a folder instead of a file.

Here is my version of index.js

'use strict';

// dependencies
var through = require('through2');
var path = require('path');

module.exports = function(ext, replaceExt) {
    var extension_replace = function(file, encoding, callback) {
        replaceExt = replaceExt || false;
        var expr;

        if (typeof ext === 'string' && ext.length > 0) {
            ext = ext.indexOf('.') === 0 ? ext : '.' + ext;
            expr = new RegExp('\\' + path.extname(file.path) + '$', 'g');
            file.path = file.path.replace(replaceExt ? replaceExt : expr, ext);
        }

        callback(null, file);
    };

    return through.obj(extension_replace);
};

Check the expr = new RegExp('\\' + path.extname(file.path) + '$', 'g'); line

Calling ext_replace multiple times in a pipe goes wrong

I am using gulp-save to save and restore the content and write to different files. My approach is to have source.js create three different files: [source.nl.js, source.de.js, source.en.js]. But calling ext_replace multiple times creates [source.nl.js, source.de.js, source.de.en.js] and that is not what I want. So I've created this version (no replace anymore!:)

module.exports = function(ext, replaceExt) {
    var extension_replace = function(file, encoding, callback) {
        replaceExt = replaceExt || false;

        if (typeof ext === 'string' && ext.length > 0) {
            ext = ext.indexOf('.') === 0 ? ext : '.' + ext;
            var firstextensiondot = file.path.lastIndexOf('\\');
            var fullnamewithoutextension = file.path.substring(0, file.path.substring(firstextensiondot).indexOf('.') + firstextensiondot)
            file.path = fullnamewithoutextension + ext;
        }

        callback(null, file);
    };

    return through.obj(extension_replace);
};

Unclear what 2 arguments does

In your readme:

If you have a slightly more involved extension you'd like to replace like .min.css, you can tell the plugin to replace that instead of the default behavior by passing in a second variable to ext_replace in the following example:

That's probably clear as day to you, but not to a mere mortal ๐Ÿ˜ƒ
I have no idea what the second argument is supposed to do. How does it replace by two different extensions? Or rather, what does it replace by what?

I would suggest adding a bit more explanation to it, and preferably also an example before / after view for this "more involved" scenario. Whatever that means ๐Ÿค”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.