How to use the walkdir.walk function in walkdir

To help you get started, we’ve selected a few walkdir 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 itchio / itch / test / chrome / static / index.html View on Github external
},
      }
    });
  }

  var Mocha = require('mocha');

  var mocha = new Mocha();
  mocha.ui('bdd').reporter(isCi ? 'tap' : 'html');

  var query = Mocha.utils.parseQuery(window.location.search || '');
  if (query.grep) mocha.grep(query.grep);
  if (query.invert) mocha.invert();

  // Read all test files.
  var walker = require('walkdir').walk(require('path').dirname(__dirname), {
    no_recurse: true
  });

  walker.on('file', function(file) {
    if (/-spec.js/.test(file))
      mocha.addFile(file);
  });

  walker.on('end', function() {
    var runner = mocha.run(function() {
      Mocha.utils.highlightTags('code');
      if (isCi) {
        ipc.send('process.exit', runner.failures);
      }
    });
  });
github itchio / itch / test / main.es6 View on Github external
import {walk} from 'walkdir'

// Read all test files.
let walker = walk(__dirname, { no_recurse: true })

walker.on('file', function (file) {
  let matches = file.match(/([^\/^\\]+-spec).js$/)
  if (!matches) return
  let modpath = `./${matches[1]}`
  require(modpath)
})
github andrewrk / groovebasin / lib / library.js View on Github external
function startScan(self) {
  if (self.library != null) return;

  self.library = {};
  console.log('starting library scan');
  var start_time = new Date();
  var pend = new Pend();
  pend.max = 20;
  var musicPath = maybeAddTrailingSlash(self.musicLibPath);
  var walker = walk.walk(musicPath);
  walker.on('file', function(filename, stat) {
    if (ignoreFile(filename)) return;
    pend.go(function(cb) {
      var stream = fs.createReadStream(filename);
      var parser = new MusicMetadataParser(stream);
      var localFile = path.relative(self.musicLibPath, filename);
      var metadata = null;
      parser.on('mime', function(mime) {
        // this event is fired when we know that it is an audio file
        // we will add it to the library whether or not it has metadata.
        metadata = defaultMetaData;
      });
      parser.on('metadata', function(md) {
        metadata = md;
      });
      parser.on('done', function() {
github electron / electron / spec-main / index.js View on Github external
mochaOptions.reporterOptions = {
      reporterEnabled: process.env.MOCHA_MULTI_REPORTERS
    }
  }
  const mocha = new Mocha(mochaOptions)

  if (!process.env.MOCHA_REPORTER) {
    mocha.ui('bdd').reporter('tap')
  }
  mocha.timeout(30000)

  if (argv.grep) mocha.grep(argv.grep)
  if (argv.invert) mocha.invert()

  // Read all test files.
  const walker = require('walkdir').walk(__dirname, {
    no_recurse: true
  })

  // This allows you to run specific modules only:
  // npm run test -match=menu
  const moduleMatch = process.env.npm_config_match
    ? new RegExp(process.env.npm_config_match, 'g')
    : null

  const testFiles = []
  walker.on('file', (file) => {
    if (/-spec\.[tj]s$/.test(file) &&
        (!moduleMatch || moduleMatch.test(file))) {
      testFiles.push(file)
    }
  })
github electron / electron / spec / static / index.html View on Github external
}
  const mocha = new Mocha(mochaOptions)

  if (!process.env.MOCHA_REPORTER) {
    mocha.ui('bdd').reporter('tap')
  }
  mocha.timeout(30000)

  const query = Mocha.utils.parseQuery(window.location.search || '')
  if (query.grep) mocha.grep(query.grep)
  if (query.invert) mocha.invert()

  const files = query.files ? query.files.split(',') : undefined

  // Read all test files.
  const walker = require('walkdir').walk(path.dirname(__dirname), {
    no_recurse: true
  })

  // This allows you to run specific modules only:
  // npm run test -match=menu
  const moduleMatch = process.env.npm_config_match
    ? new RegExp(process.env.npm_config_match, 'g')
    : null

  const testFiles = []
  walker.on('file', (file) => {
    if (/-spec\.js$/.test(file) && (!moduleMatch || moduleMatch.test(file))) {
      testFiles.push(file)
    }
  })

walkdir

Find files simply. Walks a directory tree emitting events based on what it finds. Presents a familiar callback/emitter/a+sync interface. Walk a tree of any depth.

MIT
Latest version published 5 years ago

Package Health Score

73 / 100
Full package analysis