UNPKG

@swift-ws/gulp-kit

Version:

A starter kit for automating frontend development using Gulp.js.

17 lines (15 loc) 718 B
import {relative, join} from 'path'; export const applyReplacements = (config, stream) => { if (config.replacements && Array.isArray(config.replacements) && config.replacements.length > 0) { config.replacements.forEach(replacement => { stream = stream.pipe(gIf(file => { const relativeFilePath = relative(process.cwd(), file.path); return replacement.files.some(filePattern => { const normalizedPattern = join(...filePattern.split(/[\/\\]/)); return relativeFilePath.includes(normalizedPattern); }); }, replace(replacement.find, replacement.replace))); }); } return stream; };