Gulp. How to remove duplicated functions decelerations in merged file

226 views Asked by At

I use 'gulp-concat' to merge several files into a single one. However, overwrite files are present. These files contain functions that are already declared. The previously declared functions should be deleted in this case. Is there a way to filter this out?

Example:

script

concat = require('gulp-concat')

gulp.src(['file1', 'file2'])
.pipe(concat('merge'))
.pipe(gulp.dest('dest/'));

file1

function A () {...}
function B () {return x}
function C () {...}

file2

function B () {return y}
function D () {...}
function E () {...}

merge

function A () {...}
function B () {return x}
function C () {...}
function B () {return y}
function D () {...}
function E () {...}

What I want to have:

function A () {...}
function C () {...}
function B () {return y}
function D () {...}
function E () {...}

Does anyone know a plugin or solution to fix my problem?

0

There are 0 answers