* Declare a dependency from one project in the graph to another * * @param {object} map Adjacency map to use * @param {string} fromProjectName Name of the depending project * @param {string} toProjectName Name of project on which the other depends
(map, fromProjectName, toProjectName)
| 219 | * @param {string} toProjectName Name of project on which the other depends |
| 220 | */ |
| 221 | _declareDependency(map, fromProjectName, toProjectName) { |
| 222 | if (!this._projects.has(fromProjectName)) { |
| 223 | throw new Error( |
| 224 | `Unable to find depending project with name ${fromProjectName} in project graph`); |
| 225 | } |
| 226 | if (!this._projects.has(toProjectName)) { |
| 227 | throw new Error( |
| 228 | `Unable to find dependency project with name ${toProjectName} in project graph`); |
| 229 | } |
| 230 | if (fromProjectName === toProjectName) { |
| 231 | throw new Error( |
| 232 | `A project can't depend on itself`); |
| 233 | } |
| 234 | const adjacencies = map.get(fromProjectName); |
| 235 | if (adjacencies.has(toProjectName)) { |
| 236 | log.warn(`Dependency has already been declared: ${fromProjectName} depends on ${toProjectName}`); |
| 237 | } else { |
| 238 | adjacencies.add(toProjectName); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Get all direct dependencies of a project as an array of project names |
no outgoing calls
no test coverage detected