Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'theme-color($name)': name => {
name = name.getValue();
if (!colors[name]) {
throw new Error(`There is no such color as ${name}`);
}
return new sassCompiler.types.Color(...colors[name]);
},
'get-version()': () => {
options.sass.functions['image-url($img)'] = function(img) {
return new sass.types.String('url("' +
(options.sass.imagePath ?
path.join('/', options.sass.imagePath, img.getValue()) :
path.join('/', img.getValue())
) +
'")');
};
'cdnUrl($path)': _path => new sass.types.String(`url(${CDN_BASEURL}/${_path.getValue()})`),
},
custom[`${PREFIX}-file-exists($file)`] = (parameterFile) => {
const file = parameterFile.getValue();
return fss.exists(file) ? sass.types.Boolean.TRUE : sass.types.Boolean.FALSE;
};
'get-version()': () => {
return new sassCompiler.types.String(require('./package').version.toString());
},
},
custom[`${PREFIX}-inline-file($file)`] = (parameterFile) => {
const file = parameterFile.getValue();
if (fss.exists(file)) {
const data = fss.readFile(file).toString('base64');
const mimeType = mimeTypes.lookup(file);
return new sass.types.String(`url('data:${mimeType};base64,${data}')`);
}
throw new Error(`File '${file}' not found`);
};
'docsdart-read-file($file)': (parametersFile) => {
const file = parametersFile.getValue();
if (fss.exists(file)) {
return new sass.types.String(fss.readFile(file, 'utf8'));
}
throw new Error(`File '${file}' not found`);
}
}