How to use fs-readdir-recursive - 10 common examples

To help you get started, we’ve selected a few fs-readdir-recursive 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 electrode-io / electrode-native / ern-util / src / findNativeDependencies.js View on Github external
export default function findNativeDependencies (p: string) : Array {
  let result = []

  const nativeDependenciesNames = new Set()

  const nodeModulesDirectoriesWithNativeCode = readDir(p)
          .filter(a =>
            a.includes('build.gradle') ||
            a.includes('.pbxproj') ||
            API_PATH_RE.test(a))

  // By convention we only assume react native plugins to be in directories
  // which names are starting with 'react-native' (excluding scope)
  const nativeDepsDirectories = _.filter(nodeModulesDirectoriesWithNativeCode,
          d => d.includes('react-native') && !/sample|demo|example/i.test(d))

  for (const nativeDepsDirectory of nativeDepsDirectories) {
    const pathSegments = nativeDepsDirectory.split(path.sep)
    if (pathSegments[0].startsWith('@')) {
      nativeDependenciesNames.add(`${pathSegments[0]}/${pathSegments[1]}`)
    } else {
      nativeDependenciesNames.add(pathSegments[0])
github ebdrup / json-schema-benchmark / testRunner.js View on Github external
function readTests(dirpath) {
  return require("fs-readdir-recursive")(dirpath).reduce(function(acc, value) {
    return acc.concat(require(path.join(dirpath, value)));
  }, []);
}
github babel / babel / packages / babel-cli / src / babel / util.js View on Github external
export function readdir(
  dirname: string,
  includeDotfiles: boolean,
  filter?: ReaddirFilter,
): Array {
  return readdirRecursive(dirname, (filename, _index, currentDirectory) => {
    const stat = fs.statSync(path.join(currentDirectory, filename));

    if (stat.isDirectory()) return true;

    return (
      (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename))
    );
  });
}
github electrode-io / electrode-native / ern-container-gen-ios / src / IosGenerator.ts View on Github external
public async addResources(config: ContainerGeneratorConfig) {
    const containerProjectPath = path.join(
      config.outDir,
      'ElectrodeContainer.xcodeproj',
      'project.pbxproj'
    )
    const containerIosProject = await this.getIosContainerProject(
      containerProjectPath
    )

    const containerResourcesPath = path.join(
      config.outDir,
      'ElectrodeContainer',
      'Resources'
    )
    const resourceFiles = readDir(containerResourcesPath)
    resourceFiles.forEach(resourceFile => {
      containerIosProject.addResourceFile(
        path.join('Resources', resourceFile),
        null,
        containerIosProject.findPBXGroupKey({ name: 'Resources' })
      )
    })

    fs.writeFileSync(containerProjectPath, containerIosProject.writeSync())
  }
github electrode-io / electrode-native / ern-container-gen / src / generators / ios / IosGenerator.js View on Github external
async addResources (outputDirectory: any) {
    log.debug('=== ios: adding resources for miniapps')
    const containerProjectPath = path.join(outputDirectory, 'ElectrodeContainer.xcodeproj', 'project.pbxproj')
    const containerIosProject = await this.getIosContainerProject(containerProjectPath)

    const containerResourcesPath = path.join(outputDirectory, 'ElectrodeContainer', 'Resources')
    readDir(containerResourcesPath, resourceFile => {
      containerIosProject.addResourceFile(path.join('Resources', resourceFile), null, containerIosProject.findPBXGroupKey({name: 'Resources'}))
    })
    log.debug('---iOS: Finished adding resource files.')

    fs.writeFileSync(containerProjectPath, containerIosProject.writeSync())
  }
github electrode-io / electrode-native / ern-api-impl-gen / src / generators / android / ApiImplAndroidGenerator.js View on Github external
static getMustacheFileNamesMap (resourceDir, apiName) {
    const files = readDir(resourceDir, (f) => (f.endsWith('.mustache')))
    const classNames = {
      'requestHandlers.mustache': `${apiName}ApiRequestHandler.java`,
      'requestHandlerProvider.mustache': `${apiName}ApiRequestHandlerProvider.java`,
      'apiController.mustache': `${apiName}ApiController.java`
    }
    return {files, classNames}
  }
github electrode-io / electrode-native / ern-container-gen-android / src / AndroidGenerator.ts View on Github external
)
    mustacheView.implementations = this.buildImplementationStatements(
      dependencies,
      versions
    )

    log.debug(
      `Implementation statements to be injected: ${JSON.stringify(
        mustacheView.implementations
      )}`
    )

    injectPluginsKaxTask.succeed(injectPluginsTaskMsg)

    log.debug('Patching hull')
    const files = readDir(
      config.outDir,
      f => !f.endsWith('.jar') && !f.endsWith('.aar') && !f.endsWith('.git')
    )
    const pathLibSrcMain = path.normalize('lib/src/main')
    const pathLibSrcMainJniLibs = path.normalize('lib/src/main/jniLibs')
    const pathLibSrcMainAssets = path.normalize('lib/src/main/assets')
    const pathLibSrcMainJavaCom = path.join(pathLibSrcMain, 'java/com')
    const pathLibSrcMainJavaComWalmartlabsErnContainer = path.join(
      pathLibSrcMainJavaCom,
      'walmartlabs/ern/container'
    )
    for (const file of files) {
      if (
        (file.startsWith(pathLibSrcMainJavaCom) &&
          !file.startsWith(pathLibSrcMainJavaComWalmartlabsErnContainer)) ||
        file.startsWith(pathLibSrcMainAssets) ||
github electrode-io / electrode-native / ern-container-gen / src / copyRnConfigAssets.ts View on Github external
platform,
}: {
  compositePath: string
  outDir: string
  platform: NativePlatform
}) {
  const dirs = await findDirectoriesHavingRnConfig(compositePath)

  for (const dir of dirs) {
    const rnConfig: any = require(path.join(dir, 'react-native.config.js'))
    const assets =
      rnConfig.assets || (rnConfig.dependency && rnConfig.dependency.assets)
    if (assets) {
      for (const assetDir of assets) {
        const absDir = path.join(dir, assetDir)
        readDir(absDir)
          .filter(p => {
            return supportedAssetsExts.includes(path.extname(p))
          })
          .map(p => path.join(assetDir, p))
          .forEach(p => {
            handleCopyDirective(dir, outDir, [
              { source: p, dest: getAssetsPath(platform, 'fonts') },
            ])
          })
      }
    }
  }
}
github electrode-io / electrode-native / ern-container-gen / src / generators / android / AndroidGenerator.ts View on Github external
)
          }

          if (pluginConfig.android.dependencies) {
            for (const dependency of pluginConfig.android.dependencies) {
              log.debug(`Adding compile '${dependency}'`)
              mustacheView.pluginCompile.push({
                compileStatement: `compile '${dependency}'`,
              })
            }
          }
        }
      }

      log.debug('Patching hull')
      const files = readDir(
        config.outDir,
        f => !f.endsWith('.jar') && !f.endsWith('.aar') && !f.endsWith('.git')
      )
      const pathLibSrcMain = path.join('lib', 'src', 'main')
      const pathLibSrcMainAssets = path.join('lib', 'src', 'main', 'assets')
      const pathLibSrcMainJavaCom = path.join(pathLibSrcMain, 'java', 'com')
      const pathLibSrcMainJavaComWalmartlabsErnContainer = path.join(
        pathLibSrcMainJavaCom,
        'walmartlabs',
        'ern',
        'container'
      )
      for (const file of files) {
        if (
          (file.startsWith(pathLibSrcMainJavaCom) &&
            !file.startsWith(pathLibSrcMainJavaComWalmartlabsErnContainer)) ||
github electrode-io / electrode-native / ern-runner-gen / src / index.js View on Github external
host = 'localhost',
    port = '8081'
  } : {
    reactNativeDevSupportEnabled?: boolean,
    host?: string,
    port?: string
  } = {}) {
  const mustacheView = {
    miniAppName: mainMiniAppName,
    pascalCaseMiniAppName: pascalCase(mainMiniAppName),
    isReactNativeDevSupportEnabled: reactNativeDevSupportEnabled === true ? 'true' : 'false',
    packagerHost: host,
    packagerPort: port
  }
  shell.cp('-R', path.join(runnerHullPath, 'android', '*'), outDir)
  const files = readDir(path.join(runnerHullPath, 'android'),
            (f) => (!f.endsWith('.jar') && !f.endsWith('.png')))
  for (const file of files) {
    await mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile(
                path.join(outDir, file), mustacheView, path.join(outDir, file))
  }
}

fs-readdir-recursive

Recursively read a directory

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis

Popular fs-readdir-recursive functions

Similar packages