Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "fs-readdir-recursive in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'fs-readdir-recursive' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

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])
function readTests(dirpath) {
  return require("fs-readdir-recursive")(dirpath).reduce(function(acc, value) {
    return acc.concat(require(path.join(dirpath, value)));
  }, []);
}
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))
    );
  });
}
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())
  }
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())
  }
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}
  }
)
    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) ||
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') },
            ])
          })
      }
    }
  }
}
)
          }

          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)) ||
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))
  }
}

Is your System Free of Underlying Vulnerabilities?
Find Out Now