diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-11-24 20:54:57 +0100 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-11-24 20:57:48 +0100 |
| commit | b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c (patch) | |
| tree | 49d360fd6cbc6a2754efe93524ac47ff0fbe0f7d /node_modules/postcss-cli/lib/DependencyGraph.js | |
Docs
Diffstat (limited to 'node_modules/postcss-cli/lib/DependencyGraph.js')
| -rw-r--r-- | node_modules/postcss-cli/lib/DependencyGraph.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/postcss-cli/lib/DependencyGraph.js b/node_modules/postcss-cli/lib/DependencyGraph.js new file mode 100644 index 0000000..efb7ac3 --- /dev/null +++ b/node_modules/postcss-cli/lib/DependencyGraph.js @@ -0,0 +1,30 @@ +import path from 'path' +import { DepGraph } from 'dependency-graph' + +export default function createDependencyGraph() { + const graph = new DepGraph() + return { + add(message) { + message.parent = path.resolve(message.parent) + graph.addNode(message.parent) + + if (message.type === 'dir-dependency') { + message.dir = path.resolve(message.dir) + graph.addNode(message.dir) + graph.addDependency(message.parent, message.dir) + } else { + message.file = path.resolve(message.file) + graph.addNode(message.file) + graph.addDependency(message.parent, message.file) + } + + return message + }, + dependantsOf(node) { + node = path.resolve(node) + + if (graph.hasNode(node)) return graph.dependantsOf(node) + return [] + }, + } +} |