@nx-dotnet/utils
Advanced tools
Comparing version 0.1.1 to 0.1.2-dev.1
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.1.1" | ||
"version": "0.1.2-dev.1" | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getProjectFileForNxProjectSync = exports.getProjectFileForNxProject = void 0; | ||
exports.getDependantProjectsForNxProject = exports.getProjectFileForNxProjectSync = exports.getProjectFileForNxProject = void 0; | ||
const tslib_1 = require("tslib"); | ||
const glob_1 = require("./glob"); | ||
const fs_1 = require("fs"); | ||
const xmldoc_1 = require("xmldoc"); | ||
const path_1 = require("path"); | ||
function getProjectFileForNxProject(project) { | ||
@@ -18,2 +21,29 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
exports.getProjectFileForNxProjectSync = getProjectFileForNxProjectSync; | ||
function getDependantProjectsForNxProject(targetProject, workspaceConfiguration, forEachCallback) { | ||
const projectRoots = {}; | ||
const dependantProjects = {}; | ||
Object.entries(workspaceConfiguration.projects).forEach(([name, project]) => { | ||
projectRoots[name] = path_1.resolve(project.root); | ||
}); | ||
const netProjectFilePath = getProjectFileForNxProjectSync(workspaceConfiguration.projects[targetProject]); | ||
const xml = new xmldoc_1.XmlDocument(fs_1.readFileSync(netProjectFilePath).toString()); | ||
xml.childrenNamed('ItemGroup').forEach((itemGroup) => itemGroup.childrenNamed('ProjectReference').forEach((x) => { | ||
const includeFilePath = x.attr['Include']; | ||
let absoluteFilePath; | ||
if (path_1.isAbsolute(includeFilePath)) { | ||
absoluteFilePath = includeFilePath; | ||
} | ||
else { | ||
absoluteFilePath = path_1.resolve(netProjectFilePath.split('/').slice(0, -1).join('/'), includeFilePath); | ||
} | ||
Object.entries(projectRoots).forEach(([dependency, path]) => { | ||
if (absoluteFilePath.startsWith(path)) { | ||
forEachCallback(workspaceConfiguration.projects[dependency], dependency); | ||
dependantProjects[dependency] = workspaceConfiguration.projects[dependency]; | ||
} | ||
}); | ||
})); | ||
return dependantProjects; | ||
} | ||
exports.getDependantProjectsForNxProject = getDependantProjectsForNxProject; | ||
//# sourceMappingURL=workspace.js.map |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
12278
143
2