UNPKG

atlas-guide

Version:

Atlas is living style-guides & pattern library static site generator with extensive CSS monitoring and components info that could be used virtually with any scss/css project

43 lines (33 loc) 1.09 kB
'use strict'; const path = require('path'); const sassGraph = require('sass-graph'); function getImportsGraph(atlasBaseConfig) { const sassSrcPath = atlasBaseConfig.scssSrc; const sassSrcExternalImportsPath = atlasBaseConfig.scssAdditionalImportsArray; return sassGraph.parseDir(sassSrcPath, {loadPaths: sassSrcExternalImportsPath}); } function getFileImports(relativeUrl, importsGraph) { const absUrl = path.resolve(relativeUrl); const fileInfo = importsGraph.index[absUrl]; if (!fileInfo) { return { imports: [], importedBy: [] }; } function getFileNamesOnly(pathsList) { let normalizedPaths = []; if (pathsList.length) { pathsList.forEach(absPath => normalizedPaths.push(path.basename(absPath))); } return normalizedPaths; } return { imports: getFileNamesOnly(fileInfo.imports), importedBy: getFileNamesOnly(fileInfo.importedBy) }; } module.exports = { 'getImportsGraph': getImportsGraph, 'getFileImports': getFileImports };