How to use the node-dir.readFilesStream function in node-dir

To help you get started, we’ve selected a few node-dir 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 Sotera / watchman / server / workers / tweet-processor.js View on Github external
return new Promise((res, rej) => {
    dir.readFilesStream(queuedFilesDir,
      { match: /\.json$/,
        recursive: false
      },
      (err, stream, next) => {
        if (err) return rej(err);
        console.log('found file to process: %s', stream.path);
        const lineReader = readline.createInterface({
          input: stream,
          terminal: false
        });

        lineReader
        .on('line', line => {
          let altered = alterTweet(line);
          if (altered) {
            // TODO: would be better to stream
github Sotera / watchman / server / workers / featurizer.js View on Github external
return new Promise((res, rej) => {
    dir.readFilesStream(queuedImagesDir,
      { match: /\.(jpg|jpeg|png)$/,
        recursive: false
      },
      (err, stream, next) => {
        if (err) return rej(err);
        let f = stream.path,
          renamed = f;
        console.log('found image to featurize: %s', f);
        // mark complete
        if (process.env.NODE_ENV === 'production') {
          renamed = path.join(processedImagesDir, path.basename(f));
          fs.renameSync(f, renamed);
        }
        triggerFeaturizer(renamed)
        .then(key => queue.add(key))
        .then(() => next())
github Andyccs / sqat / website / backend / jadeAutoRouting.js View on Github external
export default function jadeAutoRouting(app, excludePattern) {
  dir.readFilesStream(VIEWS_PATH, {match: /.jade$/},
    (err, stream, filename, next) => {
      if(err) {
        console.log(err);
        return;
      }

      let fileNameWithExtension = path.basename(filename);
      let fileNameWithoutExtension = path.basename(filename, '.jade');

      if(excludePattern != null &&
        fileNameWithExtension.match(excludePattern)) {
        return;
      }
      console.log('Auto route to: ./' + fileNameWithoutExtension);

      app.get('/' + fileNameWithoutExtension, function(req, resp) {

node-dir

asynchronous file and directory operations for Node.js

MIT
Latest version published 7 years ago

Package Health Score

70 / 100
Full package analysis