How to use the walkdir.sync 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 SSENSE / node-cucumber-testrail-sync / lib / ScenarioSynchronizer.js View on Github external
function readImplementedSteps(next) {
      this.implementedSteps = [];

      mkdirp(this.config.stepDefinitionsDir);
      walk.sync(this.config.stepDefinitionsDir, function (filePath) {
        if (!fs.lstatSync(filePath).isDirectory()) {
          var fileContent = fs.readFileSync(filePath).toString();

          var re = /^this\.(Given|When|Then)\((\/|')(.+)(\/|')(\w*)/;
          var stepDefinitions = fileContent.split('\n').map(Function.prototype.call, String.prototype.trim)
          .filter(function (line) {
            return re.test(line);
          })
          .map(function (line) {
            var matches = re.exec(line);

            var keyword = matches[1];
            var pattern = matches[3];
            var isStringPattern = false;

            // String Pattern
github wellcaffeinated / PhysicsJS / docs / gen-docs.js View on Github external
var dirtyFiles = [],
      ignore  = options.ignore || [],
      files   = [];

  // If more paths are given with the --source flag
  if(source.split(',').length > 1){
    var dirtyPaths = source.split(',');

    dirtyPaths.forEach(function(dirtyPath){
      dirtyFiles = dirtyFiles.concat(require('walkdir').sync(path.resolve(process.cwd(), dirtyPath),{follow_symlinks:true}));
    });
  }
  // Just one path given with the --source flag
  else {
    source  = path.resolve(process.cwd(), source);
    dirtyFiles = require('walkdir').sync(source,{follow_symlinks:true}); // tee hee!
  }

  dirtyFiles.forEach(function(file){
    file = path.relative(process.cwd(), file);

    var doNotIgnore = _.all(ignore, function(d){
      // return true if no part of the path is in the ignore list
      return (file.indexOf(d) === -1);
    });

    if ((file.substr(-2) === 'js') && doNotIgnore) {
      files.push(file);
    }
  });
  console.log(files)
  return files;
github mhevery / jasmine-node / lib / jasmine-node / spec-collection.js View on Github external
loadpaths.forEach(function(loadpath){
    wannaBeSpecs = walkdir.sync(loadpath, { follow_symlinks: true });
    for (var i = 0; i < wannaBeSpecs.length; i++) {
      var file = wannaBeSpecs[i];
      try {
        if (fs.statSync(file).isFile()) {
          if (!/.*node_modules.*/.test(path.relative(loadpath, file)) &
              matcher.test(path.basename(file))) {
            specs.push(createSpecObj(file));
          }
        }
      } catch(e) {
        // nothing to do here
      }
    }
  });
};
github jimschubert / electron-aurelia-example / spec / init.js View on Github external
var tasks = [];
  var specBaseDir = path.dirname(args.specsInit);
  var specDir = args.specsLocation;

  // creates an async task that imports a spec, then triggers the next task.
  function createTask(spec){
    return function(next){
      System.import(spec).then(function(){
        next();
      });
    }
  }

  // Synchronously walk the directory and load all specs
  walk.sync(specDir, function(file, stat){
    if (/-spec.js$/.test(file)) {
      // convert full path to relative path under spec base directory without .js extension
      // also, prefix with spec: for jspm alias (defined in test.js)
      var spec = file.replace(specBaseDir, '').replace(/^\//, '').replace(/^/, 'spec:').replace(/.js$/, '');
      tasks.push(createTask(spec));
    }
  });

  // Load all jasmine tests, then execute the test runner.
  async.waterfall(tasks, function(){
    window.jasmine.getEnv().execute();
  });
})();
github Syncano / syncano-node / packages / cli / src / utils / sockets / utils.js View on Github external
const searchForSockets = (socketsPath, maxDepth = 3) => {
  if (!fs.existsSync(socketsPath)) {
    return []
  }
  const sockets = []

  const options = {
    'follow_symlinks': true,
    'max_depth': maxDepth
  }

  // TODO: optimize only diging deeper scoped modues
  walkdir.sync(socketsPath, options, (walkPath, stat) => {
    if (walkPath.match(/socket.yml$/) && !path.dirname(walkPath).match(/\/\./)) {
      const socket = YAML.load(fs.readFileSync(walkPath, 'utf8')) || {}
      sockets.push([walkPath, socket])
    }
  })

  return sockets
}
github youzan / felint / src / utils / checkPackage.js View on Github external
function getAllNodeModules(pathStr) {
    let modules = [];
    try {
        modules = walk.sync(pathStr, {
            no_recurse: true
        });
    } catch (e) {
        modules = [];
    }

    modules.forEach((moduleName) => {
        // 私包
        if (moduleName[0] === '@') {
            modules = modules.concat(getAllNodeModules(`${pathStr}/${moduleName}`));
        }
    });
    return modules;
}
github nickjanssen / angus / core / gulp / html.js View on Github external
var autoInclude = {
        css: '',
        jsLib: '',
        jsApp: ''
    };

    if (angus.env !== 'prod') {
        autoInclude.css = angus.appConfig.bower.filesNeeded.css
        .map(function (filePath) {
            filePath = 'assets/bower_components/' + filePath;
            return '';
        }).join('\n    ');
    }

    walkDir.sync(angus.appPath + '/dist/assets/', {
        'max_depth': 1
    }, function (filePath) {
        if (path.extname(filePath) === '.css') {
            filePath = filePath.replace(angus.appPath + path.sep + 'dist' + path.sep, '');
            autoInclude.css += '\n    ';
        }
    });

    // We could also walk the directory, but we want to make sure that the order of inclusion stays intact
    // so we make the script tags manually. If we are on prod, no need to include libraries as
    // these are already present inside main.css, which we already include below.
    if (angus.env !== 'prod') {
        autoInclude.jsLib = angus.appConfig.bower.filesNeeded.js
        .map(function (filePath) {
            filePath = 'js/bower_components/' + filePath;
            return '';
github nickjanssen / angus / core / gulpfile.js View on Github external
'appName': path.basename(appPath),
        'appConfig': appConfig
    };

    // Load core tasks related to Angus itself
    walkDir.sync('./core/gulp/', function (filePath) {
        var name = path.basename(filePath, '.js');
        gulp.task(name, function (cb) {
            gutil.log(gutil.colors.cyan('Running task: ') + gutil.colors.magenta(name));
            return require(filePath)(angus, gulp)(cb);
        });
    });

    // Load app tasks which can be run using `angus ` from that app directory
    if (fs.existsSync(appPath + '/tasks/')) {
        walkDir.sync(appPath + '/tasks/', function (filePath) {
            var name = path.basename(filePath, '.js');
            gulp.task(name, function (cb) {
                gutil.log(gutil.colors.cyan('Running app task: ') + gutil.colors.blue(name));
                return require(filePath)(angus, gulp)(cb);
            });
        });
    }

    var fullBuildTags = [
        'check',
        'js',
        'clean',
        'html',
        'assets',
        'css'
    ];
github mozilla / persona-gmail-bridge / test / jshint.js View on Github external
describe('JSHint', function () {
  var rcPath = path.join(__dirname, '..', '.jshintrc');
  var rcFile = fs.readFileSync(rcPath, 'utf8');
  var configuration = JSON.parse(rcFile);

  var commonPath = path.join(__dirname, '..');

  var files = Array.prototype.concat(
    path.join(__dirname, '..', 'bin', 'persona-gmail-bridge.js'),
    walk.sync(path.join(__dirname, '..', 'lib')),
    walk.sync(path.join(__dirname, '..', 'scripts')),
    walk.sync(path.join(__dirname, '..', 'static')),
    walk.sync(path.join(__dirname, '..', 'test'))
  );

  files = files.filter( function(file) {
    return (/\.js$/).test(file) && !(/\/i18n\/.*\/messages\.js$/).test(file);
  } );

  files.forEach(function (file) {
    var relativeName = file.substring(commonPath.length);
    it(relativeName + ' should pass', function () {
      var source = fs.readFileSync(file, 'utf8');
      if (!jshint(source, configuration)) {
        throw new Error('JSHint failed.\n' + format(jshint.errors));
      }
github wellcaffeinated / PhysicsJS / docs / gen-docs.js View on Github external
dirtyPaths.forEach(function(dirtyPath){
      dirtyFiles = dirtyFiles.concat(require('walkdir').sync(path.resolve(process.cwd(), dirtyPath),{follow_symlinks:true}));
    });
  }

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