How to use the @microsoft/rush-lib.PackageDependencyKind.Optional function in @microsoft/rush-lib

To help you get started, we’ve selected a few @microsoft/rush-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / rushstack / rush / rush / src / actions / LinkAction.ts View on Github external
if (startingCyclicSubtree) {
            // If we are starting a new subtree, then newLocalPackage will be its root
            // NOTE: cyclicSubtreeRoot is guaranteed to be undefined here, since we never start
            // a new tree inside an existing tree
            newCyclicSubtreeRoot = newLocalPackage;
          }

          resolution.parentForCreate.addChild(newLocalPackage);
          queue.push({
            commonPackage: commonDependencyPackage,
            localPackage: newLocalPackage,
            cyclicSubtreeRoot: newCyclicSubtreeRoot
          });
        }
      } else {
        if (dependency.kind !== PackageDependencyKind.Optional) {
          throw Error(`The dependency "${dependency.name}" needed by "${localPackage.name}"`
            + ` was not found the ${rushConfiguration.commonFolderName} folder -- do you need to run "rush generate"?`);
        } else {
          console.log(colors.yellow('Skipping optional dependency: ' + dependency.name));
        }
      }
    }
  }

  // When debugging, you can uncomment this line to dump the data structure
  // to the console:
  // localProjectPackage.printTree();

  createSymlinksForTopLevelProject(localProjectPackage);

  // Also symlink the ".bin" folder