Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { parseFile, parseDir, Graph } from "sass-graph";
// Example copied from readme:
// https://github.com/xzyfer/sass-graph/blob/master/readme.md
const graph1: Graph = parseFile("test/fixtures/main.scss");
const graph2: Graph = parseDir("test/fixtures");
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const sassGraph = require('sass-graph');
const graph = sassGraph.parseFile('./src/components/_index.scss');
const root = Object.keys(graph.index)[0];
const content = recursiveReadSCSS(root, graph.index[root]);
fs.writeFileSync('./dist/theme.scss', content);
function recursiveReadSCSS(branchId, branch) {
if (branch.imports.length === 0) {
return fs.readFileSync(branchId, 'utf8');
}
const file = fs.readFileSync(branchId, 'utf8');
const sassFileContent = [];
branch.imports.forEach((branchId) => {
const content = recursiveReadSCSS(branchId, graph.index[branchId]);
sassFileContent.push(content);
watcher.reset = function(opts) {
config = clonedeep(opts || config || {});
var options = {
loadPaths: config.includePath,
extensions: ['scss', 'sass', 'css'],
follow: config.follow,
};
if (config.directory) {
graph = grapher.parseDir(config.directory, options);
} else {
graph = grapher.parseFile(config.src, options);
}
return Object.keys(graph.index);
};
Watcher.prototype.getIncludedFiles = function() {
var newWatchedFilesGraph = grapher.parseFile(this.inputPath, {
loadPaths: this.includePaths,
extensions: this.includeExtensions
});
return Object.keys(newWatchedFilesGraph.index);
};