Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function requireParser(isSCSSParser) {
if (isSCSSParser) {
return require("postcss-scss");
}
// TODO: Remove this hack when this issue is fixed:
// https://github.com/shellscape/postcss-less/issues/88
const LessParser = require("postcss-less/dist/less-parser");
LessParser.prototype.atrule = function() {
return Object.getPrototypeOf(LessParser.prototype).atrule.apply(
this,
arguments
);
};
return require("postcss-less");
}
switch (fileNameExtension(file)) {
case "sass":
console.error('TODO: Sass not implemented yet, file will be empty!');
postcssSass.process(code).result.root;
sassFiles++;
break;
case "scss":
console.error('TODO: Sass not implemented yet, file will be empty!');
postcssScss.parse(code);
scssFiles++;
break;
case "less":
console.error('TODO: Sass not implemented yet, file will be empty!');
postcssLess.parse(code);
lessFiles++;
break;
case "css":
tss = transformCSStoTSS(postcssCss.parse(code));
destinationFile = destinationFile.replace('.css', '.tss.ts');
cssFiles++;
}
if (!existsSync(destinationDirectory)) {
mkdirSync(destinationDirectory);
}
process.chdir(destinationDirectory);
writeFileSync(destinationFile, tss);
LessParser.prototype.atrule = function() {
return Object.getPrototypeOf(LessParser.prototype).atrule.apply(
this,
arguments
);
};
parse (source) {
return postcss([]).process(source, {
from: this.fullPath,
parser: postcssLess.parse,
stringifier: postcssLess.stringify,
});
}