index.js
function(url, done) {

      var urlParts = urlUtil.parse(url, true),
          filename = urlParts.pathname,
          auth = urlParts.auth;

      if (S(filename).endsWith("/")) filename += "index"; // Append

      var filePath = path.resolve(
                      process.cwd(),
                      outPath,
                      S(urlParts.hostname).replaceAll("\\.", "-").s,
                      "./" + filename + "." + format),
      args = [captureScript, url, filePath, '--username', username,
        '--password', password, '--paper-orientation', paperOrientation,
        '--paper-margin', paperMargin, '--paper-format', paperFormat,
        '--viewport-width', viewportWidth, '--viewport-height', viewportHeight];

      var phantom = childProcess.execFile(phantomPath, args, function(err, stdout, stderr) {
        if (verbose && stdout) console.log("---\nPhantomJS process stdout [%s]:\n" + stdout + "\n---", phantom.pid);
        if (verbose && stderr) console.log("---\nPhantomJS process stderr [%s]:\n" + stderr + "\n---", phantom.pid);
        if (verbose) console.log("Rendered %s to %s", url, filePath);
        done(err);
      });
      if (verbose)
        console.log("Spawning PhantomJS process [%s] to rasterize '%s' to '%s'", phantom.pid, url, filePath);
    }
function(url, done) {

      var urlParts = urlUtil.parse(url, true),
          filename = urlParts.pathname,
          auth = urlParts.auth;

      if (S(filename).endsWith("/")) filename += "index"; // Append

      var filePath = path.resolve(
                      process.cwd(),
                      outPath,
                      S(urlParts.hostname).replaceAll("\\.", "-").s,
                      "./" + filename + "." + format),
      args = [captureScript, url, filePath, '--username', username,
        '--password', password, '--paper-orientation', paperOrientation,
        '--paper-margin', paperMargin, '--paper-format', paperFormat,
        '--viewport-width', viewportWidth, '--viewport-height', viewportHeight];

      var phantom = childProcess.execFile(phantomPath, args, function(err, stdout, stderr) {
        if (verbose && stdout) console.log("---\nPhantomJS process stdout [%s]:\n" + stdout + "\n---", phantom.pid);
        if (verbose && stderr) console.log("---\nPhantomJS process stderr [%s]:\n" + stderr + "\n---", phantom.pid);
        if (verbose) console.log("Rendered %s to %s", url, filePath);
        done(err);
      });
      if (verbose)
        console.log("Spawning PhantomJS process [%s] to rasterize '%s' to '%s'", phantom.pid, url, filePath);
    }
function ( url , done ) { var urlParts = urlUtil . parse ( url , true ) , filename = urlParts . pathname , auth = urlParts . auth ; if ( S ( filename ) . endsWith ( "/" ) ) filename += "index" ; // Append var filePath = path . resolve ( process . cwd ( ) , outPath , S ( urlParts . hostname ) . replaceAll ( "\\." , "-" ) . s , "./" + filename + "." + format ) , args = [ captureScript , url , filePath , '--username' , username , '--password' , password , '--paper-orientation' , paperOrientation , '--paper-margin' , paperMargin , '--paper-format' , paperFormat , '--viewport-width' , viewportWidth , '--viewport-height' , viewportHeight ] ; var phantom = childProcess . execFile ( phantomPath , args , function ( err , stdout , stderr ) { if ( verbose && stdout ) console . log ( "---\nPhantomJS process stdout [%s]:\n" + stdout + "\n---" , phantom . pid ) ; if ( verbose && stderr ) console . log ( "---\nPhantomJS process stderr [%s]:\n" + stderr + "\n---" , phantom . pid ) ; if ( verbose ) console . log ( "Rendered %s to %s" , url , filePath ) ; done ( err ) ; } ) ; if ( verbose ) console . log ( "Spawning PhantomJS process [%s] to rasterize '%s' to '%s'" , phantom . pid , url , filePath ) ; }
For each url
For each url