How to use dependency-cruiser - 4 common examples

To help you get started, we’ve selected a few dependency-cruiser 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 BabylonJS / Babylon.js / Tools / Gulp / tasks / gulpTasks-dependencies.js View on Github external
const dependencies = function(settings, moduleName, cb) {
    var cruiseResult = depcruise.cruise(
        [path.relative(path.resolve("./"), settings.computed.mainDirectory)],
        {
            validate: true,
            ruleSet: {
                forbidden: [{
                    name: 'no-circular',
                    comment: 'circular dependencies will make you dizzy',
                    severity: 'error',
                    from: {},
                    to: {
                        circular: true
                    }
                }],
                options: {
                    doNotFollow: "node_modules",
                    tsConfig: {
github art-software / art-core / packages / art-webpack-miniprogram / dist / compiler / dependencyTree.js View on Github external
exports.dependencyTree = (entry) => {
    if (!entry.length) {
        return [];
    }
    const cruiseResult = dependency_cruiser_1.cruise(entry, {
        outputType: 'json',
        preserveSymlinks: true
    });
    const dependencies = JSON.parse(cruiseResult.modules).modules;
    return dependencies.filter((dependency) => {
        return dependency.coreModule !== true;
    }).map((notCoreDependency) => {
        let depPath = path_1.join(paths_1.default.appCwd, notCoreDependency.source);
        return depPath = isDevStage ? depPath.replace('packages', 'node_modules') : depPath;
    });
};
github art-software / art-core / packages / art-webpack-miniprogram / src / compiler / dependencyTree.ts View on Github external
export const dependencyTree = (entry: string[]): string[] => {

  if (!entry.length) { return []; }

  const cruiseResult = cruise(
    entry,
    {
      outputType: 'json',
      preserveSymlinks: true
    }
  );

  const dependencies = JSON.parse(cruiseResult.modules).modules;

  return dependencies.filter((dependency) => {
    return dependency.coreModule !== true;
  }).map((notCoreDependency) => {
    let depPath = join(paths.appCwd, notCoreDependency.source);
    return depPath = isDevStage ? depPath.replace('packages', 'node_modules') : depPath;
  });
};
github waningflow / CodeRoad / util / index.js View on Github external
function getDepcruise(params) {
  if(!params){
    throw new Error('params is required')
  }
  const { rootPath, aliasPath, excludePattern } = params
  const exePath = process.cwd()
  let absPath = path.resolve(exePath, rootPath)
  const alias = aliasPath ? require(path.resolve(exePath, aliasPath)) : {}
  const exts = defaultAllowExt.slice()
  const exclude = defaultExcludePattern
    .concat(excludePattern)
    .map(v => `(${v})`)
    .join('|')
  const excludeReg = new RegExp(exclude)
  const extReg = new RegExp(`\\.(${exts.join('|')})$`)
  let dependencies = depcruise([absPath], {
    exclude: excludeReg
  })

  let dirtrees = dirtree(absPath, {
    extensions: extReg,
    exclude: excludeReg
  })
  let fileList = getFileList(dirtrees)
  let aliasModules = []
  dependencies.modules = dependencies.modules.map(v => {
    v.source = path.resolve(exePath, v.source)
    v.dependencies = v.dependencies
      .filter(dv => !dv.coreModule)
      .map(dv => {
        dv.resolved = path.resolve(exePath, dv.resolved)
        if (dv.dependencyTypes && dv.dependencyTypes[0] === 'unknown') {

dependency-cruiser

Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.

MIT
Latest version published 18 days ago

Package Health Score

95 / 100
Full package analysis

Popular dependency-cruiser functions