How to use directory-tree - 10 common examples

To help you get started, we’ve selected a few directory-tree 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 flow-typed / flow-typed / definitions / npm / directory-tree_v2.x.x / flow_v0.104.x- / test_directory-tree_v2.x.x.js View on Github external
it('type error', () => {
    // $ExpectError
    const expectNumber: number = dirTree(__dirname);
  });
github timberio / gitdocs / static.config.js View on Github external
if (!config.version) {
    config.version = require(path.resolve(ROOT, 'package.json')).version // eslint-disable-line
  }

  if (config.syntax) {
    process.env.GITDOCS_SYNTAX = JSON.stringify(config.syntax)
  }

  if (config.sidebar && config.sidebar.items) {
    tree = mapTree(config.sidebar.items, item => ({
      ...item,
      src: item.src ? path.resolve(DOCS_SRC, item.src) : '',
    }))
  } else {
    // Pull out the markdown files in the /docs directory
    tree = dirTree(DOCS_SRC, { extensions: /\.md/ }).children

    // Add root readme to file tree
    tree.unshift({
      name: 'Introduction',
      src: 'README.md',
      order: -Infinity,
    })

    // Filter out public and empty directories
    tree = tree.filter(d => d.name !== 'public')
  }

  tree = mapTree(tree, item => {
    const fullFileName = item.src ? item.src.split('#')[0] : ''
    const fileName = fullFileName.replace('.md', '')
    try {
github flow-typed / flow-typed / definitions / npm / directory-tree_v2.x.x / flow_v0.104.x- / test_directory-tree_v2.x.x.js View on Github external
it('use exclude array', () => {
    const exclude: Array = [/some_path_to_exclude/];
    exclude.push(/test/);

    const useExcludeArray: dirTreeType = dirTree(__dirname, {
      exclude,
    });
  });
github flow-typed / flow-typed / definitions / npm / directory-tree_v2.x.x / flow_v0.104.x- / test_directory-tree_v2.x.x.js View on Github external
it('use exclude array', () => {
    const exclude: $ReadOnlyArray = [/some_path_to_exclude/, /test/];
    const useExcludeReadOnlyArray: dirTreeType = dirTree(__dirname, {
      exclude,
    });
  });
github flow-typed / flow-typed / definitions / npm / directory-tree_v2.x.x / flow_v0.104.x- / test_directory-tree_v2.x.x.js View on Github external
it('use options', () => {
    const useOptions: dirTreeType = dirTree(__dirname, {
      normalizePath: patthString => true,
      exclude: /some_path_to_exclude/,
      extensions: /\.js$/,
    });
  });
github flow-typed / flow-typed / definitions / npm / directory-tree_v2.x.x / flow_v0.104.x- / test_directory-tree_v2.x.x.js View on Github external
it('use onEachFile', () => {
    const useOnEachFile: dirTreeType = dirTree(__dirname, null, (item, PATH) => {
      const { path, name } = item;
      const pathname: string = PATH.resolve(path, name);
    });
  });
github MichalLytek / type-graphql / tests / regression / structure.ts View on Github external
posts  Post[]
      }

      model Post {
        uuid      String  @id @default(cuid())
        content   String
        author    User
        color     Color
      }
    `;

    await generateCode(
      await getPhotonDmmfFromPrismaSchema(schema),
      baseDirPath,
    );
    const directoryStructure = directoryTree(baseDirPath);
    const directoryStructureString =
      "\n[type-graphql]\n" +
      stringifyDirectoryTrees(directoryStructure.children, 2);

    expect(directoryStructureString).toMatchInlineSnapshot(`
      "
      [type-graphql]
        [enums]
          Color.ts
          index.ts
          OrderByArg.ts
        index.ts
        [models]
          index.ts
          Post.ts
          User.ts
github sneas / component-library / src / assemblers / templates.js View on Github external
search: 'Search',
        js: [],
        css: [],
        layout: path.join(__dirname, 'views/layout.njk'),
        favicon: {
            href: options.baseUrl + 'assets_/assets/favicons/favicon-32x32.png',
            rel: 'icon',
            type: 'image/component-library/favicons/png'
        }
    });

    nunjucksEnv = (new nunjucks.configure([path.join(__dirname, 'views'), '']))
        .addFilter('template', path => fs.readFileSync(path).toString())
        .addFilter('highlight', code => hljs.highlight('htmlbars', code, true, false).value);

    const patternsTree = dirTree(inputDir);
    patternsTree.name = options.overview;
    refineTree(patternsTree, inputDir);

    return compileTree(patternsTree, outputDir, patternsTree, options);
}
github petersamokhin / nodejs-markdown-site / lib / utils / generate-table-of-contents.js View on Github external
export default function generateNavigationForFolder (folder, userRoles, callback) {
  const tree = dirTree(folder, {extensions: /\.md/}, (item) => {
    item.path = item.path.substring(item.path.indexOf('/pages')).replace('.md', '')
    item.name = item.name.replace('.md', '')
  })
  tree.children.forEach(item => {
    validatePathsRecursive(item)
  })

  getAccessMapForFolderChildren(folder, userRoles, map => {
    generateNavigationByNodes(tree.children, map, callback)
  })
}

directory-tree

Convert a directory tree to a JS object.

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis

Popular directory-tree functions