How to use the hexo-fs.readdir function in hexo-fs

To help you get started, we’ve selected a few hexo-fs 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 hexojs / hexo-cli / lib / console / init.js View on Github external
  }).then(() => fs.readdir(target)).map(path => pathFn.join(target, path)).filter(path => fs.stat(path).then(stats => stats.isDirectory())).each(removeGitDir);
}
github hexojs / hexo / lib / box / index.js View on Github external
Box.prototype._readDir = function(base, fn, prefix = '') {
  const { ignore } = this;

  if (base && ignore) {
    if (ignore.length && isMatch(base, ignore)) {
      return Promise.resolve([]);
    }
  }

  return readdir(base).map(path => stat(join(base, path)).then(stats => {
    const fullpath = join(base, path);
    if (stats.isDirectory()) {
      return this._readDir(fullpath, fn, `${prefix + path}/`);
    }

    if (ignore && ignore.length && isMatch(fullpath, ignore)) {
      return Promise.resolve([]);
    }

    return this._checkFileStatus(prefix + path).then(file => fn(file).thenReturn(file));
  })).catch(err => {
    if (err.cause && err.cause.code === 'ENOENT') return;
    throw err;
  }).reduce((files, item) => files.concat(item), []);
};
github hexojs / hexo / lib / hexo / load_config.js View on Github external
function findConfigPath(path) {
  const { dir, name } = parse(path);

  return fs.readdir(dir).then(files => {
    const item = files.find(item => item.startsWith(name));
    if (item != null) return join(dir, item);
  });
}