How to use the node-dir.promiseFiles function in node-dir

To help you get started, we’ve selected a few node-dir 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 trufflesuite / truffle / packages / debug-utils / index.js View on Github external
gatherArtifacts: async function(config) {
    // Gather all available contract artifacts
    let files = await dir.promiseFiles(config.contracts_build_directory);

    var contracts = files
      .filter(file_path => {
        return path.extname(file_path) === ".json";
      })
      .map(file_path => {
        return path.basename(file_path, ".json");
      })
      .map(contract_name => {
        return config.resolver.require(contract_name);
      });

    await Promise.all(
      contracts.map(abstraction => abstraction.detectNetwork())
    );
github atomiclabs / hyperdex / app / portfolio-util.js View on Github external
const getPortfolios = async () => {
	let portfolioFiles;
	try {
		portfolioFiles = await dir.promiseFiles(portfoliosDirectoryPath);
	} catch (error) {
		if (error.code === 'ENOENT') {
			return [];
		}

		throw error;
	}

	portfolioFiles = portfolioFiles.filter(file => file.endsWith('.json'));

	const portfolios = await Promise.all(portfolioFiles.map(async filePath => {
		const portfolio = await loadJsonFile(filePath);
		portfolio.fileName = path.basename(filePath);
		portfolio.id = fileNameToId(portfolio.fileName);

		// TODO: Remove this sometime far in the future when everyone has migrated
github doyensec / electronegativity / src / util / file.js View on Github external
export function list_files(input){
  return dir.promiseFiles(input)
    .then(files => {
      files = files.filter(file => {
        return file.indexOf('node_modules') === -1 && (['js', 'jsx', 'ts', 'tsx', 'html', 'htm'].includes(extension(file)) || file.toLowerCase().indexOf('package.json') > -1);
      });
      return files;
    })
    .catch(console.error);
}
github ayakashi-io / ayakashi / src / runner / loaders.ts View on Github external
export async function loadLocalPreloaders(connection: IConnection, projectFolder: string, storeProjectFolder: string) {
    const localPreloadersDir = pathResolve(projectFolder, "preloaders");
    if (existsSync(localPreloadersDir)) {
        const localPreloaders: string[] = await dir.promiseFiles(localPreloadersDir);
        const localPreloaderDefinitions = localPreloaders
        .filter(function(preloader) {
            return preloader.includes(".js") && !preloader.includes(".map");
        })
        .map(function(preloader) {
            return {
                module: preloader,
                as: null,
                waitForDOM: false
            };
        });
        await loadPreloaders(
            connection,
            localPreloaderDefinitions,
            projectFolder,
            storeProjectFolder,
github eclipse / codewind / src / pfe / portal / modules / metricsService / index.js View on Github external
async function getPathToMainAppClassFile(projectDir) {
  const pathToProjectSrcFiles = path.join(projectDir, 'src', 'main', 'java');

  const srcFiles = await dir.promiseFiles(pathToProjectSrcFiles);

  const mainAppClassFile = await findAsync(
    srcFiles,
    async(file) => {
      const fileData = await fs.readFile(file, 'utf8');
      const fileIsMainAppClassFile = fileData.includes(springAppAnnotation);
      if (fileIsMainAppClassFile) {
        return file;
      }
      throw new Error();
    },
  );
  return mainAppClassFile;
}
github ngx-rocket / core / lib / file-utilities.js View on Github external
static async getFiles(templatePath, generatorType) {
    let promises;
    switch (generatorType) {
      case 'fullstack':
        promises = [
          dir.promiseFiles(
            path.join(templatePath, FileUtilities.ClientTemplatesPath)
          ),
          dir.promiseFiles(
            path.join(templatePath, FileUtilities.ServerTemplatesPath)
          ),
          dir.promiseFiles(
            path.join(templatePath, FileUtilities.RootTemplatesPath)
          )
        ];
        break;
      case 'server':
        promises = [[], dir.promiseFiles(templatePath), []];
        break;
      default:
        promises = [dir.promiseFiles(templatePath), [], []];
    }
github ngx-rocket / core / lib / file-utilities.js View on Github external
dir.promiseFiles(
            path.join(templatePath, FileUtilities.ClientTemplatesPath)
          ),
          dir.promiseFiles(
            path.join(templatePath, FileUtilities.ServerTemplatesPath)
          ),
          dir.promiseFiles(
            path.join(templatePath, FileUtilities.RootTemplatesPath)
          )
        ];
        break;
      case 'server':
        promises = [[], dir.promiseFiles(templatePath), []];
        break;
      default:
        promises = [dir.promiseFiles(templatePath), [], []];
    }

    const files = await Promise.all(promises);
    return {
      client: files[0],
      server: files[1],
      root: files[2]
    };
  }
github alibaba / ice / packages / iceworks-server / src / lib / adapter / modules / oss / index.ts View on Github external
async upload(args, ctx: IContext): Promise {
    const { i18n } = ctx;
    const oss = this.storage.get('oss');
    const params: IOSSUploadParams = oss.find(({ project }) => project === this.project.path);

    const buildPath = path.join(this.project.path, this.buildDir);
    if (!await pathExists(buildPath)) {
      throw new Error(i18n.format('baseAdapter.oss.upload.dirEmptyError', {buildDir: this.buildDir}));
    }

    const files = await dir.promiseFiles(buildPath);
    if (!files.length) {
      throw new Error(i18n.format('baseAdapter.oss.upload.buildEmptyError'));
    }

    const { bucket, directory, region } = params;
    const aliOSS = new AliOSS({...params, endpoint: `${region}.${DOMAIN}`});
    await aliOSS.setBucket(bucket);

    return await Promise.all(files.map(async (file) => {
      const fileRelativePath = path.relative(buildPath, file);
      const storeFilepath = path.join(directory, fileRelativePath)
        .replace(/\\/g, '/')
        .replace(/^\//, '');

      let result: IUploadResult;
      try {
github Typeform / openapi-micro-merge / lib / index.js View on Github external
exports.preparePromise = function(specDir, specFile, infoFile, host, schemes, basePath, options) {
  validate(options, constraints);
  return dir.promiseFiles(specDir)
  .then((files) => {
    return files.filter(function(file) {
      return file.endsWith(specFile);
    });
  })
  .then((files) => {
    return Promise.all(files.map(function(file) {
      return SwaggerParser.validate(file, {
        "allowUnknown": false,
      });
    }))
    .then((apis) => {
      SwaggerMerge.on('warn', function (msg) {
        throw new Error(msg);
      });
      var info = yaml.safeLoad(fs.readFileSync(infoFile, 'utf8'));

node-dir

asynchronous file and directory operations for Node.js

MIT
Latest version published 7 years ago

Package Health Score

70 / 100
Full package analysis