@nx-dotnet/utils
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -7,5 +7,6 @@ { | ||
"glob": "^7.1.6", | ||
"rimraf": "^3.0.2" | ||
"rimraf": "^3.0.2", | ||
"xmldoc": "^1.1.2" | ||
}, | ||
"version": "0.1.2" | ||
"version": "0.1.3" | ||
} |
"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,32 @@ 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)) { | ||
if (forEachCallback) { | ||
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
12410
146
3
2
+ Addedxmldoc@^1.1.2
+ Addedsax@1.4.1(transitive)
+ Addedxmldoc@1.3.0(transitive)