How to use the filehound.create function in filehound

To help you get started, we’ve selected a few filehound 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 acheronfail / ColorCode / scripts / build-codemirror.js View on Github external
process.popdir();

// Copy over the files we use from CodeMirror.
console.log('Copying necessary files...');
fse.removeSync(CM_DEST);
fse.ensureDirSync(CM_DEST);
for (let i = 0; i < CM_ADDONS.length; ++i) {
  fse.ensureDirSync(path.dirname(CM_DEST_ADDONS[i]));
  fse.copySync(CM_ADDONS[i], CM_DEST_ADDONS[i]);
}
fse.copySync(CM_THEMES, CM_DEST_THEMES);
fse.copySync(CM_MODES, CM_DEST_MODES);
fse.copySync(CM_LIBS, CM_DEST_LIBS);

// Strip copied directories of unnecessary files.
FileHound.create()
  .paths(CM_DEST_MODES)
  .find((err, files) => {
    if (err) throw err;
    files.map((filepath) => {
      // Only keep '.js' files in these directories.
      if (path.extname(filepath) != '.js') {
        fse.removeSync(filepath);
      }
    });

    console.log('Complete!');
    process.exit();
  });

// Helpers ---------------------------------------------------------------------
github toolbuddy / papoGen / lib / compile_engine_md.js View on Github external
compile_engine_md.gen_doc_md = function(src_path, title, out_path, theme) {
    // fetch and generate
    const files = fh.create().paths(src_path).ext('md').find((err, files) => {
        if (err)
            return;
        else {
            // strip out the files under node_modules
            for (var index = 0;; index++) {
                if (files[index] == undefined) break;
                if (files[index].indexOf('node_modules') != -1) {
                    files.splice(index, 1);
                    index--;
                }
            }
            // list out existed -> files 
            console.log("After exclude useless md:")
            console.dir(files);
            let fnamelist = utils.fetch(files, "md");
            // copy the buffer to dest
github balena-io / balena-cli / automation / build-bin.ts View on Github external
const xpaths: Array<[string, string[]]> = [
		// [platform, [path, to, file]]
		['*', ['opn', 'xdg-open']],
		['darwin', ['denymount', 'bin', 'denymount']],
	];
	await Bluebird.map(xpaths, ([platform, xpath]) => {
		if (platform === '*' || platform === process.platform) {
			// eg copy from node_modules/opn/xdg-open to build-bin/xdg-open
			return fs.copy(
				path.join(ROOT, 'node_modules', ...xpath),
				path.join(ROOT, 'build-bin', xpath.pop()!),
			);
		}
	});
	const nativeExtensionPaths: string[] = await filehound
		.create()
		.paths(path.join(ROOT, 'node_modules'))
		.ext(['node', 'dll'])
		.find();

	console.log(`\nCopying to build-bin:\n${nativeExtensionPaths.join('\n')}`);

	await Bluebird.map(nativeExtensionPaths, extPath =>
		fs.copy(
			extPath,
			extPath.replace(
				path.join(ROOT, 'node_modules'),
				path.join(ROOT, 'build-bin'),
			),
		),
	);
github jy95 / torrent-files-library / src / TorrentLibrary.js View on Github external
scan() {
    const foundFiles = FileHound.create()
      .paths((this.paths.length === 0) ? this.defaultPath : this.paths)
      .ext(videosExtension)
      .find();

    return new PromiseLib((resolve, reject) => {
      foundFiles
        .then(files => this.addNewFiles(files)).then(() => {
          this.emit('scan', { files: foundFiles });
          resolve('Scanning completed');
        }).catch((err) => {
          this.emit('error_in_function', {
            functionName: 'scan',
            error: err.message,
          });
          reject(err);
        });
github captbaritone / webamp / experiments / skinArchiveTools / lib / collectSkins.js View on Github external
module.exports = async function collectSkins({ inputDir, cache }) {
  console.log("Searching for files in", inputDir);
  const paths = new Set();
  Object.values(cache).forEach(skin => {
    skin.filePaths.forEach(filePath => {
      paths.add(filePath);
    });
  });
  const files = await Filehound.create()
    .ext(["zip", "wsz", "wal"])
    .paths(inputDir)
    .find();

  console.log(`Found ${files.length} potential files`);

  let i = 0;
  const interval = setInterval(() => {
    console.log(`Checked ${i} files...`);
  }, 10000);
  await Bluebird.map(
    files,
    async filePath => {
      if (paths.has(filePath)) {
        return;
      }
github captbaritone / webamp / experiments / automatedScreenshots / index.js View on Github external
(async () => {
  const shooter = new Shooter();
  const passedSkin = process.argv[2];
  let files = [];
  if (passedSkin) {
    files.push(passedSkin);
  } else {
    files = await Filehound.create()
      .ext("wsz")
      .paths("skins/")
      .find();
  }

  for (const skin of files) {
    console.log("Trying", skin);
    const skinMd5 = md5File.sync(skin);
    const screenshotPath = `screenshots/${skinMd5}.png`;
    if (fs.existsSync(screenshotPath)) {
      console.log(screenshotPath, "exists already");
      continue;
    }
    await shooter.takeScreenshot(path.join(__dirname, skin), screenshotPath, {
      minify: true
    });
github tadejstanic / wp-hrm-webpack / scripts / utils.js View on Github external
function getScreenshot(path) {
  return fileHound
    .create()
    .paths(path)
    .depth(0)
    .glob("screenshot.png")
    .find();
}
github olzzon / casparcg-state-scanner / src / utils / getFolderStructure.ts View on Github external
function _getDirectories(path: string) {
    return FileHound.create()
    .path(path)
    .directory()
    .findSync();
}
github bbc / async-workshop / patterns / lib / asyncify.js View on Github external
const path = require('path');
const Filehound = require('filehound');

function qualify(file) {
  return path.join(__dirname, path.basename(file));
}

function getName(file) {
  return path.basename(file, '.js');
}

function whoami() {
  return getName(__filename);
}

const files = Filehound.create()
  .path('./lib')
  .ext('js')
  .discard(`.*${whoami()}`, 'private')
  .findSync();

for (const file of files) {
  module.exports[getName(file)] = require(qualify(file));
}

filehound

Find files the easy way

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis

Popular filehound functions