Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
const path = require('path');
const fs = require('fs');
const times = require('lodash/times');
const escapeRegExp = require('lodash/escapeRegExp');
const sizeOf = require('image-size');
const datauri = require('datauri').sync;
let types;
/* eslint-disable prefer-destructuring */
try {
types = require('node-sass').types;
} catch (e) {
types = require('gulp-sass/node_modules/node-sass').types; //eslint-disable-line import/no-unresolved
}
/* eslint-enable prefer-destructuring */
module.exports = (options) => {
const paths = require('../../gulp-config/paths');
const rootPath = paths.toAbsPath('src.root');
const imgPath = paths.toAbsPath('src.assets/images');
const baseRegExp = new RegExp('^' + escapeRegExp(rootPath + path.sep));
const baseUrl = '/' + paths.toAbsPath('src.assets/images').replace(baseRegExp, '').replace(path.sep, '/').trim('/') + '/';
const getFilePath = (filepath) => {
const imagePath = path.join(imgPath, filepath.getValue());
if (!fs.existsSync(imagePath)) {
console.warn('File %s not found', imagePath); //eslint-disable-line no-console