Encode summary to provide an API to plugin

@param {Output} output
@param {Config} config
@return {Object}
323024
function encodeSummary(output, summary) {
    var result = {
        /**
            Iterate over the summary, it stops when the "iter" returns false

            @param {Function} iter
        */
        walk: function (iter) {
            summary.getArticle(function(article) {
                var jsonArticle = encodeSummaryArticle(article, false);

                return iter(jsonArticle);
            });
        },

        /**
            Get an article by its level

            @param {String} level
            @return {Object}
        */
        getArticleByLevel: function(level) {
            var article = summary.getByLevel(level);
            return (article? encodeSummaryArticle(article) : undefined);
        },

        /**
            Get an article by its path

            @param {String} level
            @return {Object}
        */
        getArticleByPath: function(level) {
            var article = summary.getByPath(level);
            return (article? encodeSummaryArticle(article) : undefined);
        }
    };

    return result;
}
1107845
function output(data, format) {
    switch(format) {
        case 'json':
            return json(data, 2);
        case 'min':
            return json(data);
        case 'unix':
            return unix(data);
        default:
            throw `Invalid format: ${format}`;
    }
}
463476
function formatConfig(config) {
  const result = {
    appenders: {
      out: { type: 'console' }
    },
    categories: {
      default: {
        appenders: ['out'],
        level: 'info'
      }
    }
  }
  for (const appender of config.appenders) {
    result.appenders[appender.type] = Object.assign({}, appender)
    ;(result.categories[appender.category] ||
      (result.categories[appender.category] = {
        appenders: [],
        level: 'info'
      }))['appenders'].push(appender.type)
  }
  return result
}
708310
static void encode(Environment environment, LocalFunctionRegistry registry, Class returnType, Object result, OutputStream output) throws IOException {
        if (ClassUtils.isJavaLangType(returnType)) {
            if (result instanceof Byte) {
                output.write((Byte) result);
            } else if (result instanceof Boolean) {
                output.write(((Boolean) result) ? 1 : 0);
            } else if (result instanceof byte[]) {
                output.write((byte[]) result);
            } else {
                byte[] bytes = environment
                    .convert(result.toString(), byte[].class)
                    .orElseThrow(() -> new InvocationException("Unable to convert result [" + result + "] for output stream"));
                output.write(bytes);
            }
        }
822917
function renderToString(meta) {
  if (meta.html) return meta.html.source
  var output = [
    '<!DOCTYPE html>', '<html>', '<head>', '<meta charset="utf8" />'
  ]
  var { head, body } = meta
  head.metas.forEach(e => output.push(renderMeta(e.name, e.http, e.content)))
  head.styles.forEach(e => output.push(renderStyle(e.type, e.src, e.source)))
  head.scripts.forEach(e => output.push(renderScript(e.type, e.src, e.source)))
  if (head.title) output.push(`<title>${head.title}</title>`)
  if (head.icon) output.push(renderIcon(head.icon.type, head.icon.src))
  output.push('</head>', '<body>')
  if (body.holder) output.push(body.holder.source)
  body.injectA.forEach(e => output.push(renderScript(e.type, e.src, e.source)))
  body.scripts.forEach(e => output.push(renderScript(e.type, e.src, e.source)))
  body.injectB.forEach(e => output.push(renderScript(e.type, e.src, e.source)))
  output.push('</body>', '</html>')
  return concatString(output)
}
271289
function plugin(config) {

    checkProperty(config, 'url');

    return function(files, metalsmith, done){
        // initialize the API
        Prismic.Api(config['url'], retrieveContent, config['accessToken']);

        function retrieveContent(err, api) {
            if (err) {
                console.error("Could not initialize API: " + err);
            }
            else {

                // obtain the reference
                var release = config['release'];
                var ref;
                var ctx = {};
                for (var currentRef in api.data.refs) {
                    if ((!release || release.toLowerCase() == "master") && (api.data.refs[currentRef].isMaster)) {
                        ref = api.data.refs[currentRef].ref;
                    }
                    else if (release == api.data.refs[currentRef].label) {
                        ref = api.data.refs[currentRef].ref;
                    }
                }

                // user release as reference if no reference found
                if (!ref) {
                  ref = release || 'master';
                }

                // setup the context object
                ctx.api = api;
                ctx.linkResolver = getLinkResolver(ctx);
                ctx.htmlSerializer = config['htmlSerializer'] || function() {};
                ctx.ref = ref;
                ctx.OAuth = config['accessToken'];

                each(Object.keys(files), function (fileName, callback) {
                    retrieveContentForFile(fileName, callback, ctx)
                }, function(err) {debug("metalsmith-prismic done!"); done(err)})
            }
        }

        function getLinkResolver(ctx) {
            return function(doc, isBroken) {
                if (config['linkResolver'] != undefined) {
                    return config['linkResolver'](ctx, doc);
                } else {
                    if (isBroken) return false;
                    return '/' + doc.type + '/' + doc.id + '/' + doc.slug + (ctx.maybeRef ? '?ref=' + ctx.maybeRef : '');
                }
            }
        }

        // retrieves and processes the content for the given filename
        function retrieveContentForFile(fileName, callback, ctx) {
            var file = files[fileName];
            if (file.prismic) {
                debug("Pulling in content for file: %s", fileName);
                var queryKeys = {};
                var collectionQuery;

                // create associative array of query keys and their query & formName
                for (var queryKey in file.prismic) {
                    debug("processing %s", queryKey);
                    file.prismic[queryKey].results = [];
                    var queryString = file.prismic[queryKey].query;
                    var bookmark = file.prismic[queryKey].bookmark;
                    var orderings = file.prismic[queryKey].orderings;
                    var fetchLinks = file.prismic[queryKey].fetchLinks;
                    var pageSize = file.prismic[queryKey].pageSize;
                    var allPages = file.prismic[queryKey].allPages;
                    var formName = file.prismic[queryKey].formName;
                    if (formName == null) {
                        formName = "everything"
                    }
                    var collectionMetaData = file.prismic[queryKey].collection;
                    if (collectionMetaData != null) {
                        if (collectionQuery != null) {
                            throw new TypeError('Only one query can be designated the collection query. Please update the configuration settings appropriately.');
                        } else if (typeof collectionMetaData != "boolean" && file.prismic[queryKey].collection.fileExtension == null) {
                            throw new TypeError('The file extension to use when generating the files for the collection must be specified.');
                        } else if (collectionMetaData === true || typeof collectionMetaData != "boolean") {
                            collectionQuery = queryKey;
                        }
                    }
                    queryKeys[queryKey] = {"queryString": queryString,
                                           "bookmark": bookmark,
                                           "pageSize": pageSize,
                                           "allPages": allPages,
                                           "orderings": orderings,
                                           "fetchLinks": fetchLinks,
                                           "formName": formName};
                }

                // asynchronously retrieve and process each query
                each(Object.keys(queryKeys), function (currentQueryKey, queriedAndProcessedCallback) {
                    debug("%s: api.form(\"%s\").query('%s').ref(ctx.ref).submit()", queryKey, formName, queryString);
                    var totalPages;
                    var page = 1;

                    if (queryKeys[currentQueryKey].queryString) {
                        // fetch by query
                        queryNextPage();
                    } else if (queryKeys[currentQueryKey].bookmark) {
                        // fetch by bookmark
                        var bookmarkID = ctx.api.bookmarks[queryKeys[currentQueryKey].bookmark];
                        if (bookmarkID) {
                            ctx.api.getByID(bookmarkID, {}, prismicBookmarkCallback);
                        } else {
                            // Missing bookmark, leave data empty
                            queriedAndProcessedCallback();
                        }
                    } else {
                        throw new TypeError('Must specify either query or bookmark');
                    }

                    function queryNextPage() {
                        ctx.api.form(queryKeys[currentQueryKey].formName)
                            .query(queryKeys[currentQueryKey].queryString)
                            .pageSize(queryKeys[currentQueryKey].pageSize)
                            .page(page)
                            .orderings(queryKeys[currentQueryKey].orderings)
                            .fetchLinks(queryKeys[currentQueryKey].fetchLinks)
                            .ref(ctx.ref).submit(prismicQueryCallback);
                    }

                    function prismicQueryCallback(err, d) {
                        if (err) {
                            queriedAndProcessedCallback(err);
                        }
                        else {
                            processRetrievedContent(d, file.prismic, currentQueryKey, ctx);
                            totalPages = d.total_pages;
                            if (queryKeys[currentQueryKey].allPages &&
                                page < totalPages) {
                                page++;
                                queryNextPage();
                            } else {
                                queriedAndProcessedCallback();
                            }
                        }
                    }

                    function prismicBookmarkCallback(err, d) {
                        if (err) {
                            queriedAndProcessedCallback(err);
                        } else {
                            file.prismic[currentQueryKey] = processRetrievedDocument(d, file.prismic, currentQueryKey, ctx);
                            queriedAndProcessedCallback();
                        }
                    }

                }, function(err){
                    if(err != null) {
                        console.log(err);
                        callback(err);
                        return;
                    }
                    generateCollectionFiles(fileName, collectionQuery, callback, ctx);
                });
            } else {
                callback();
            }
        }

        // processes the retrieved content and adds it to the metadata
        function processRetrievedContent(content, filePrismicMetadata, queryKey, ctx) {
            if (content.results != null && content.results.length > 0) {
                var queryMetadata = filePrismicMetadata[queryKey];
                for (var i = 0; i < content.results.length; i++) {
                    var result = processRetrievedDocument(content.results[i], filePrismicMetadata, queryKey, ctx);
                    filePrismicMetadata[queryKey].results.push(result);
                }
            }
        }

        // processes and return single retrieved document
        function processRetrievedDocument(document, filePrismicMetadata, queryKey, ctx) {
            // add the complete result except for the data fragments
            var result = _.omit(document, 'fragments');
            result.data = {};

            // process the data fragments, invoking helpers to make the data more usable
            if (document.fragments != null && Object.keys(document.fragments).length  > 0) {
                for (var fragmentFullName in document.fragments) {

                    // strip the document type from the fragment name
                    var fragmentName = fragmentFullName.substr(fragmentFullName.lastIndexOf('.') + 1);

                    var fragment = document.fragments[fragmentFullName];
                    result.data[fragmentName] = processSingleFragment(fragment, ctx, filePrismicMetadata[queryKey]);
                }
            }

            return result;
        }

        // process a single fragment, and return the fragment object with json and html data
        function processSingleFragment(fragment, ctx, queryMetadata) {
          // return array fragments (link[0], link[1], ... named fragments) as arrays if arrayFragments are enabled
          if (Array.isArray(fragment)) {
            if (queryMetadata.arrayFragments) {
              return fragment.map(function(subFragment) {
                return processSingleFragment(subFragment, ctx, queryMetadata);
              });
            } else {
              // only return first element of array
              if (fragment.length) {
                return processSingleFragment(fragment[0], ctx, queryMetadata);
              } else {
                // only return one element of empty array, lets say that is null
                return null;
              }
            }
          }

          // initialize Prismic fragment javascript wrapper, unless already initialized
          if (!fragment.asHtml) {
            fragment = Prismic.Fragments.initField(fragment);
          }
          var fragmentObject = {
            json: fragment
          };

          if (!queryMetadata.output || queryMetadata.output.indexOf('html') > -1) {
            fragmentObject.html = fragment.asHtml(ctx.linkResolver, ctx.htmlSerializer);
          }

          if (queryMetadata.output && queryMetadata.output.indexOf('text') > -1) {
            //  https://github.com/prismicio/javascript-kit/issues/104
            if (!(fragment instanceof Prismic.Fragments.SliceZone) && !(fragment instanceof Prismic.Fragments.SliceZone)) {
              fragmentObject.text = fragment.asText(ctx.linkResolver);
            }
          }

          // Add child fragments
          if (fragment instanceof Prismic.Fragments.DocumentLink && fragment.document.data) {
            // from document links
            fragmentObject.children = _.mapObject(fragment.document.data[fragment.type], function(subFragment) {
              if (subFragment.type) {
                return processSingleFragment(subFragment, ctx, queryMetadata);
              } else {
                // some document link subfragments aren't proper fragments
                // for example StructuredText isn't supported
                // we can't really do anything else than return the raw data
                return {
                  json: subFragment
                };
              }
            });
          } else if (fragment instanceof Prismic.Fragments.Group) {
            // from groups
            fragmentObject.children = _.map(fragment.toArray(), function(group) {
              return _.mapObject(group.fragments, function(subFragment) {
                return processSingleFragment(subFragment, ctx, queryMetadata);
              });
            });
          } else if (fragment instanceof Prismic.Fragments.SliceZone) {
            // TODO
            fragmentObject.children = _.map(fragment.value, function(sliceFragment) {
              var subFragmentObject = processSingleFragment(sliceFragment.value, ctx, queryMetadata);
              subFragmentObject.sliceType = sliceFragment.sliceType;
              subFragmentObject.sliceLabel = sliceFragment.label;
              return subFragmentObject;
            });
          }

          // Add fragment url
          if (fragment instanceof Prismic.Fragments.DocumentLink) {
            fragmentObject.url = fragment.url(ctx.linkResolver);
          } else if (fragment instanceof Prismic.Fragments.WebLink) {
            fragmentObject.url = fragment.url();
          } else if (fragment instanceof Prismic.Fragments.FileLink) {
            fragmentObject.url = fragment.url();
          } else if (fragment instanceof Prismic.Fragments.ImageLink) {
            fragmentObject.url = fragment.url();
          } else if (fragment instanceof Prismic.Fragments.Image) {
            fragmentObject.url = fragment.url;
          }

          return fragmentObject;
        }

        // if any of the queries are designated the collection query, then generate a file for each of the results
        function generateCollectionFiles(fileName, collectionQuery, callback, ctx) {
            if (collectionQuery != null) {
                var file = files[fileName];
                var newFiles = {};
                var fileExtension = file.prismic[collectionQuery].collection.fileExtension;
                var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:"";
                // for every result in the collection query
                for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) {

                    // clone the file and replace the original collectionQuery results with the current result
                    var newFile = clone(file);
                    newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]];

                    // add the filename to the ctx object to make it available for use in the linkResolver function
                    ctx.path = fileName;

                    // use the linkResolver to generate the filename removing the leading slash if present
                    newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile;
                }

                delete files[fileName];
                _.extend(files, newFiles);
            }

            callback();
        }

    }


    function checkProperty(object, property) {
        if ((object[property]) == null) {
            throw new TypeError('Missing property \'' + property + '\'. Please update the configuration settings appropriately.');
        }
    }
}
782963
private static String formatOutput(String js, boolean export) {
    StringBuilder output = new StringBuilder();

    // Shadow window so that non-browser environments can pass their own global object here.
    output.append("(function(window){");

    // If $wnd is set to this, then JSInterop's normal export will run, and pollute the global
    // namespace. If export is false, fake out $wnd with an empty object.
    // (We also add Error to work around StackTraceCreator using it in a static block).
    output.append("var $wnd=").append(export ? "this" : "{'Error':{}}").append(";");

    // Shadow $doc, $moduleName and $moduleBase.
    output.append("var $doc={},$moduleName,$moduleBase;");

    // Append output JS.
    output.append(js);

    // 1. Export $gwtExport, needed for transpile.js
    // 2. Reset $wnd (nb. this occurs after jscompiler's JS has run)
    // 3. Call gwtOnLoad, if defined: this invokes onModuleLoad for all loaded modules.
    output.append("this['$gwtExport']=$wnd;$wnd=this;typeof gwtOnLoad==='function'&&gwtOnLoad()");

    // Overspecify the global object, to capture Node and browser environments.
    String globalObject = "this&&this.self||"
        + "(typeof window!=='undefined'?window:(typeof global!=='undefined'?global:this))";

    // Call the outer function with the global object as this and its first argument, so that we
    // fake window in Node environments, allowing our code to do things like "window.console(...)".
    output.append("}).call(").append(globalObject).append(",").append(globalObject).append(");");

    return output.toString();
  }
1071920
function replWriter(output) {
  if (output){
    if (output.constructor && output.constructor.name !== "String"){
      return util.inspect(output, {colors:true}) + '\n';
    }
  }

  return output + '\n';
}
736946
function encodeResult (result, count) {
    var output = '';
    output += (result.ok ? 'ok ' : 'not ok ') + count;
    output += result.message ? ' ' + result.message.toString().replace(/\s+/g, ' ') : '';

    if (result.skip) output += ' # SKIP';
    else if (result.todo) output += ' # TODO';

    output += '\n';
    if (result.ok) return output;

    var outer = '  ';
    var inner = outer + '  ';
    output += outer + '---\n';
    output += inner + 'operator: ' + result.operator + '\n';

    var ex = JSON.stringify(result.expected) || '';
    var ac = JSON.stringify(result.actual) || '';

    if (Math.max(ex.length, ac.length) > 65) {
        output += inner + 'expected:\n' + inner + '  ' + ex + '\n';
        output += inner + 'actual:\n' + inner + '  ' + ac + '\n';
    }
    else {
        output += inner + 'expected: ' + ex + '\n';
        output += inner + 'actual:   ' + ac + '\n';
    }
    if (result.at) {
        output += inner + 'at: ' + result.at + '\n';
    }
    if (result.operator === 'error' && result.actual && result.actual.stack) {
        var lines = String(result.actual.stack).split('\n');
        output += inner + 'stack:\n';
        output += inner + '  ' + lines[0] + '\n';
        for (var i = 1; i < lines.length; i++) {
            output += inner + lines[i] + '\n';
        }
    }

    output += outer + '...\n';
    return output;
}
1118648
function formatOutput(output) {
    var indent = '  ';
    var pad = '  ';
    var results = [];
    results.push('AppDir:' + output.appDir);
    output.suites.forEach(function(suite) {
      results.push(pad + 'Suite: ' + suite.description + ' -- ' + suite.status);
      pad+=indent;
      suite.specs.forEach(function(spec) {
        results.push(pad + spec.status + ' - ' + spec.description);
        if (spec.failedExpectations) {
          pad+=indent;
          spec.failedExpectations.forEach(function (fe) {
            results.push(pad + 'message: ' + fe.message);
          });
          pad=pad.substr(2);
        }
      });
      pad = pad.substr(2);
      results.push('');
    });
    results.push('');
    return results.join('\n');
  }
592252
function encodeOutputToJson(output) {
    var book = output.getBook();
    var generator = output.getGenerator();
    var options = output.getOptions();

    var result = encodeBook(book);

    result.output = {
        name: generator
    };

    result.options = options.toJS();

    return result;
}
660728
function copyPluginAssets(output) {
    var book = output.getBook();

    // Don't copy plugins assets for language book
    // It'll be resolved to the parent folder
    if (book.isLanguageBook()) {
        return Promise(output);
    }

    var plugins = output.getPlugins()

        // We reverse the order of plugins to copy
        // so that first plugins can replace assets from other plugins.
        .reverse();

    return Promise.forEach(plugins, function(plugin) {
        return copyAssets(output, plugin)
        .then(function() {
            return copyResources(output, plugin);
        });
    })
    .thenResolve(output);
}
1329097
function encodeOutputWithPage(output, page) {
    var file = page.getFile();
    var book = output.getBook();

    var result = encodeOutput(output);
    result.page = encodePage(page, book.getSummary());
    result.file = encodeFile(file);

    return result;
}
365840
def process_output(meta_file, outfile_name, code_links):
    '''
    '''

    # Markdown title line
    doc_str = '# ' + meta_file['header'] + '\n'
    doc_str += 'Generated by [py2md](https://github.com/gbowerman/py2md) on '
    doc_str += strftime("%Y-%m-%d %H:%M:%S ") + '\n\n'

    # Create a table of contents if more than one module (i.e. more than one
    # source file)
    if len(meta_file['modules']) > 1:
        doc_str += "## Contents\n"
        chapter_num = 1
        for meta_doc in meta_file['modules']:
            chapter_name = meta_doc['summary_comment']
            chapter_link = chapter_name.lstrip().replace('.', '').replace(' ', '-').lower()
            doc_str += str(chapter_num) + \
                '. [' + chapter_name + '](#' + chapter_link + ')\n'
            chapter_num += 1


    # Document each meta-file
    for meta_doc in meta_file['modules']:
        doc_str += '## ' + meta_doc['summary_comment'] + '\n'
        doc_str += '[source file](' + meta_doc['source_file'] + ')' + '\n'
        for function_info in meta_doc['functions']:
            doc_str += '### ' + function_info['name'] + '\n'
            doc_str += function_info['definition'] + '\n\n'
            if 'comments' in function_info:
                doc_str += '```\n' + function_info['comments'] + '\n```\n\n'

    # write the markdown to file
    print('Writing file: ' + outfile_name)
    out_file = open(outfile_name, 'w')
    out_file.write(doc_str)
    out_file.close()
1093237
function writeSummary(output) {
    var options = output.getOptions();
    var prefix = options.get('prefix');

    var filePath = SUMMARY_FILE;
    var engine = WebsiteGenerator.createTemplateEngine(output, filePath);
    var context = JSONUtils.encodeOutput(output);

    // Render the theme
    return Templating.renderFile(engine, prefix + '/summary.html', context)

    // Write it to the disk
    .then(function(tplOut) {
        return writeFile(output, filePath, tplOut.getContent());
    });
}
1035542
function parseInputOutput(buildConfig, fileExtensions, runtimeOptions) {
  let outputs, outputIsDirectory;

  // Parse output
  if (buildConfig.output) {
    outputs = buildConfig.output;

    if (!Array.isArray(outputs)) outputs = [outputs];

    // Use compressed if specified
    if (runtimeOptions.compress && 'output_compressed' in buildConfig) {
      let outputsCompressed = buildConfig.output_compressed;

      if (!Array.isArray(outputsCompressed)) outputsCompressed = [outputsCompressed];
      if (outputsCompressed.length != outputs.length) {
        throw Error(
          `total number of outputs (${strong(buildConfig.output)}) do not match total number of compressed outputs (${strong(buildConfig.output_compressed)})`
        );
      }
      outputs = outputsCompressed;
      buildConfig.output = buildConfig.output_compressed;
    }

    outputIsDirectory = outputs.length == 1 && !path.extname(outputs[0]).length;
  } else {
    buildConfig.outputpaths = [];
  }

  // Parse input
  if (buildConfig.input) {
    const allFileExtensions = [];
    const inputsRelative = [];
    let inputs = buildConfig.input;
    let type = '';
    let matchGenerated;

    // Gather all extensions to allow for easier filtering
    for (const type in fileExtensions) {
      allFileExtensions.push(...fileExtensions[type]);
    }

    if (!Array.isArray(inputs)) inputs = [inputs];

    // Handle common/intersection build
    if ((matchGenerated = RE_GENERATED_INPUT.exec(inputs[0]))) {
      type = 'js';
      buildConfig.inputpaths = [dummyFile];
      buildConfig.isGeneratedBuild = true;
      buildConfig.generatedInputPattern = matchGenerated[1];
    } else {
      buildConfig.inputpaths = inputs
        .reduce(
          (inputs, input) => {
            // Expand glob pattern
            if (RE_GLOB.test(input)) {
              inputs = inputs.concat(glob(input, { matchBase: true, nocase: true }));
            } else {
              inputs.push(input);
            }
            return inputs;
          },
          []
        )
        .reduce(
          (inputs, input) => {
            const hasTrailingSlash = RE_TRAILING.test(input);

            input = path.resolve(input);
            // Expand directory
            if (!path.extname(input).length) {
              // Batch mode will change output behaviour if dir -> dir
              buildConfig.batch = true;
              inputs = inputs.concat(
                readdir(input, (resource, stat) => {
                  const isFile = stat.isFile() && !RE_HIDDEN.test(path.basename(resource));

                  // Capture relative path for dir -> dir
                  // Like cp command, if trailing slash, use contents
                  if (isFile)
                    inputsRelative.push(path.relative(hasTrailingSlash ? input : path.resolve(input, '..'), resource));
                  return isFile;
                })
              );
            } else {
              inputs.push(input);
              inputsRelative.push(path.basename(input));
            }
            return inputs;
          },
          []
        )
        .filter((input, idx) => {
          const extension = path.extname(input).slice(1);
          let include = true;

          // Include/exclude if grepping
          if (runtimeOptions.grep) {
            include = buildConfig.label == runtimeOptions.grep ||
              match(input, runtimeOptions.grep, { matchBase: true, nocase: true });
            if (runtimeOptions.invert) include = !include;
          }

          // Exclude unknown files
          if (!allFileExtensions.includes(extension)) {
            warn(
              `${strong(extension)} is an unknown file type (${strong(input)}). You should install a language pack from npm to enable support. Search npm for "buddy-plugin" to see all available.`
            );
            include = false;
          }

          if (!include) inputsRelative.splice(idx, 1);
          return include;
        })
        .map(input => {
          const inputpath = path.resolve(input);
          const inputType = filepathType(inputpath, fileExtensions);

          type = !type || type == inputType ? inputType : MIXED_TYPE;

          return inputpath;
        });
    }

    // Abort if no resolved
    if (!buildConfig.inputpaths.length) {
      buildConfig.input = null;
      buildConfig.inputpaths = null;
      return;
    }

    buildConfig.type = type;

    if (outputs) {
      if (buildConfig.inputpaths.length != outputs.length && !outputIsDirectory) {
        throw Error(
          `unable to resolve inputs (${strong(buildConfig.input)}) with outputs (${strong(buildConfig[runtimeOptions.compress ? 'output_compressed' : 'output'])})`
        );
      }

      buildConfig.outputpaths = buildConfig.inputpaths.map((inputpath, idx) => {
        let outputpath = '';

        if (outputIsDirectory) {
          // Preserve relative paths when batching
          outputpath = path.join(path.resolve(outputs[0]), inputsRelative[idx]);
        } else {
          outputpath = path.resolve(outputs[idx]);
        }

        const extension = path.extname(outputpath);
        const inputType = filepathType(inputpath, fileExtensions);

        // Resolve missing extension
        if (!extension) outputpath += `.${inputType}`;
        if (inputType != 'img' && extension != `.${inputType}`)
          outputpath = outputpath.replace(extension, `.${inputType}`);

        if (outputpath === inputpath) {
          throw Error(
            `the input ${strong(buildConfig.input)} is configured to be overwritten by ${strong(buildConfig.output)}. If you're trying to build the contents of a directory, remember to add a trailing slash to ${strong(buildConfig.input)}`
          );
        }

        return outputpath;
      });
    }
  }
}
570881
function summariser(results) {
    var response = [],
        callback = function(output) {
            response.push(output);
        };

    var passed = 0;
    if (results.hasOwnProperty('passed')) {
        passed = countSpecs(results.passed);
    }
    var failed = 0;
    if (results.hasOwnProperty('failed')) {
        failed = countSpecs(results.failed);
    }
    var pending = 0;

    if (results.hasOwnProperty('pending')) {
        pending = countSpecs(results.pending);
    }
    var total = passed + failed + pending;

    coloriseOutput(total + ' Specs defined', 'bold', callback);
    if (total > 0) {
        coloriseOutput(passed + ' Passed' + displayPercentage(total, passed), 'green', callback);
        coloriseOutput(failed + ' Failed' + displayPercentage(total, failed), 'red', callback);
        coloriseOutput(pending + ' Pending' + displayPercentage(total, pending), 'yellow', callback);
    }
    return response;
}