Пример #1
0
 homeQuery.paginate(pageOptions, function (err, homes) {
   _.each(_.deepPluck(homes.results, 'listing.address.postalcode'), function(postalcode) {
     if(_.where(userParams, { 'paidInterests.zips':postalcode }).length === 0) {
       userParams.push({'paidInterests.zips':postalcode});
       console.log(postalcode);
     }
   });
   homesCallback(err, homes, callback);
 });
Пример #2
0
storage.setup(function () {
  var projects = storage.allWithDirectory();
  var padding = _.max(_.deepPluck(projects, 'name.length')) + 2;

  var directories = new utilities.DirectoryEmitter(projects);

  directories.on('directory', function (directory, project) {
    // TODO: These return in the order finished, it might be worth it to add a
    // queue so that results only print after the items before them
    // (alphabetically) but still run in parallel
    // TODO: Make less OS X/Ubuntu/bash-centric
    var bash = spawn('bash', ['-c', command],
      _.extend(spawnOptions, {
        cwd: directory,
        env: _.extend(process.env, {
          PROJECT: project.name
        })
      }));

    if (program.stdout) {
      bash.on('close', process.exit);
    } else {
      var lines = [];

      bash.stdout.pipe(split()).on('data', function (line) {
        lines.push(line);
      });

      // Display things one of three ways:
      //
      // - if there was one line of output print everything on one line
      // - if there was more than one line print it underneath the name
      // - if there were no lines of output print the project name in yellow
      bash.on('close', function () {
        lines = trimArray(lines);

        if (lines.length > 1) {
          if (program.headers) {
            console.log(chalk.green(project.name));
          }
        } else if (lines.length === 1 && program.headers) {
          process.stdout.write(chalk.green(_.padRight(project.name + ':',
            padding)));
        } else if (!program.ignoreEmptyOutput && program.headers) {
          console.log(chalk.yellow(_.padRight(project.name, padding)));
        }

        if (lines.length) {
          console.log(lines.join('\n'));
        }

        if (lines.length > 1) {
          console.log();
        }
      });
    }
  });

  if (program.warnings) {
    directories.on('missing', function (directory) {
      console.warn(chalk.yellow(directory, 'is missing.'));
    });

    directories.on('file', function (directory) {
      console.warn(chalk.yellow(directory, 'is a file, not a directory.'));
    });
  }

  directories.on('error', function (err) {
    console.error('Error:', err);

    process.exit(1);
  });
});