How to use the walk-sync.entries function in walk-sync

To help you get started, we’ve selected a few walk-sync 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 nodejs / i18n / script / collect.js View on Github external
async function getDocsForNodeVersion (major, version) {
  const docDir = path.join(__dirname, `../content/${major}/en-US/doc`)
  const tempDir = path.join(__dirname, `../temp/${major}`)

  // TODO exit early if docs for this version have already been downloaded

  // download repo bundle and extract to a temporary directory
  const tarballUrl = `https://github.com/nodejs/node/archive/${version}.tar.gz`
  console.log('downloading', tarballUrl)
  await download(tarballUrl, tempDir, {extract: true})

  // move docs from temp dir to this repo
  const tempDocDir = path.join(tempDir, `node-${version.replace('v', '')}`, 'doc')

  // removes files other than markdown
  walk(tempDocDir, {directories: false})
    .filter(file => path.extname(file.relativePath.toLowerCase()) !== '.md')
    .forEach(file => fs.unlinkSync(path.join(tempDocDir, file.relativePath)))

  await fs.copy(tempDocDir, docDir)

  fs.remove(tempDir)
}
github jex / jex / lib / load-pages.js View on Github external
module.exports = function loadPages (jexConfig) {
  const { pagesDirectory, pagesIncludePatterns: globs, pagesExcludePatterns: ignore } = jexConfig

  const pages = walk(pagesDirectory, { globs, ignore, directories: false })
    .map(entry => new Page(entry, jexConfig))

  // add named keys to the array for fast object-like URL reference
  for (const page of pages) {
    page.permalinks.forEach(permalink => {
      pages[permalink] = page
    })
  }

  return pages
}
github ef4 / ember-browserify / lib / stub-generator.js View on Github external
StubGenerator.prototype.build = function() {
  var start = Date.now();
  var inputPath = this.inputPaths[0];
  var previous  = this._previousTree;

  // get patchset
  var input = walkSync.entries(inputPath, [ '**/*.js' ]);

  debug('input: %d', input.length);

  var next = this._previousTree = FSTree.fromEntries(input);
  var patchset = previous.calculatePatch(next);

  debug('patchset: %d', patchset.length);

  var applyPatch = Date.now();

  // process patchset
  patchset.forEach(function(patch) {
    var operation = patch[0];
    var path      = patch[1];
    var fullPath  = inputPath + '/' + path;
github linkedin / css-blocks / packages / @css-blocks / broccoli / src / Aggregate.ts View on Github external
build() {
    let output = this.outputPath;
    let input = this.inputPaths[0];
    let { id, css } = this.transport;

    // Test if anything has changed since last time. If not, skip trying to update tree.
    let newFsTree = FSTree.fromEntries(walkSync.entries(input));
    let diff = this.previous.calculatePatch(newFsTree);

    // Auto-discover common preprocessor extensions.
    if (!this._out) {
      let prev = path.parse(path.join(input, this.out));
      let origExt = prev.ext;
      prev.base = ""; // Needed for path.format to register ext change
      for (let ending of COMMON_FILE_ENDINGS) {
        prev.ext = ending;
        if (fs.existsSync(path.format(prev))) { break; }
        prev.ext = origExt;
      }
      let out = path.parse(this.out);
      out.base = ""; // Needed for path.format to register ext change
      out.ext = prev.ext;
      this._out = path.format(out);
github ef4 / ember-auto-import / ts / broccoli-append.ts View on Github external
private appendedPatchset() {
    let input = walkSync.entries(this.appendedDir);
    let passthroughEntries = input
      .map(e => {
        let first = e.relativePath.split('/')[0];
        let remapped = this.passthrough.get(first);
        if (remapped) {
          let o = Object.create(e);
          o.relativePath = e.relativePath.replace(new RegExp('^' + first), remapped);
          o.isPassthrough = true;
          o.originalRelativePath = e.relativePath;
          return o;
        }
      }).filter(Boolean);

    let previous = this.previousAppendedTree;
    let next = (this.previousAppendedTree = FSTree.fromEntries(input));
    return { patchset: previous.calculatePatch(next), passthroughEntries };
github phodal / adr / src / lib / update.ts View on Github external
function updateNameByTitle (): void {
  let files = walkSync.entries(savePath, { globs: ['**/*.md'], ignore: ['README.md'] })

  files.forEach(function (file) {
    let fileName = file.relativePath
    let fileData = fs.readFileSync(savePath + fileName, 'utf8')
    let firstLine = fileData.split('\n')[0]
    let title = firstLine.replace(/#\s\d+\.\s/g, '')
    let indexRegex = /#\s(\d+)\.\s/.exec(firstLine)
    let oldIndex
    if (!indexRegex) {
      oldIndex = Utils.getIndexByString(fileName)
      if (!oldIndex) {
        return
      }
    } else {
      oldIndex = indexRegex[1]
    }
github vinz243 / cassette / src / server / features / scanner / tree.js View on Github external
const getFolderEntries = module.exports.getFolderEntries = (path) => {
   return walkSync.entries(path)
}
github ember-cli / ember-cli / lib / tasks / server / livereload-server.js View on Github external
getDirectoryEntries(directory) {
    return walkSync.entries(directory);
  }
github ef4 / ember-auto-import / packages / ember-auto-import / ts / broccoli-append.ts View on Github external
private appendedPatchset() {
    let input = walkSync.entries(this.appendedDir);
    let passthroughEntries = input
      .map(e => {
        let match = findByPrefix(e.relativePath, this.passthrough);
        if (match) {
          let o = Object.create(e);
          o.relativePath = e.relativePath.replace(new RegExp('^' + match.prefix), match.mapsTo);
          o.isPassthrough = true;
          o.originalRelativePath = e.relativePath;
          return o;
        }
      }).filter(e => e && e.relativePath !== './') as AugmentedWalkSyncEntry[];

    let previous = this.previousAppendedTree;
    let next = (this.previousAppendedTree = FSTree.fromEntries(input));
    return { patchset: previous.calculatePatch(next), passthroughEntries };
  }

walk-sync

Get an array of recursive directory contents

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis

Popular walk-sync functions

Similar packages