Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Q.all(files.map(function (file) {
var deferred = Q.defer();
var src = file.src[0];
Sass.writeFile(src, grunt.file.read(src));
if (PATH.basename(src)[0] !== '_') {
Sass.compileFile(src, function (result) {
if (result.status !== 0) {
grunt.log.error(result.formatted + '\n');
grunt.warn('');
deferred.reject();
} else {
try {
var cssFullPath = file.dest;
var content = result.text;
if (data.sourceMap && result.map) {
var cssFile = PATH.basename(cssFullPath);
content = "/*# sourceMappingURL=" + cssFile + ".map */\n" + content;
var rootDirectory = "sass/" + PATH.dirname(src);
result.map.file = cssFile;
result.map.sources = result.map.sources.map(function (source) {
return PATH.relative(rootDirectory, source).replace(/\\/g, "/");
});
wl.config.set("theme", theme);
if (wl.extension.get(theme, "path") != null) {
const themeFile = path.join(wl.extension.get(theme, "path"), wl.extension.get(theme, "main"));
const { ext } = path.parse(themeFile);
switch (ext) {
case "css":
return fs.readFile(themeFile, function(e, r){
if (e != null) { throw e; }
return $theme.html(r);
});
case "sass":
return sass.compileFile(themeFile, r=> $theme.html(r));
case "scss":
return sass.compileFile(themeFile, r=> $theme.html(r));
case "less":
return less.renderFile(themeFile, r=> $theme.html(r));
}
}
}