'use strict';

var getVersion  = require('git-repo-version');
var fs          = require('fs');
var Y           = require('yuidocjs');

module.exports = {
  generate: function generateYuidocOptions(){
    var config;
    var exclusions = [
      '.DS_Store',
      '.git',
      'node_modules',
      'vendor',
      'bower_components',
      'tmp',
      'tests'
    ];

    try {
      config = JSON.parse(fs.readFileSync('yuidoc.json'));
    } catch(e){
      console.log("No yuidoc.json file in root folder. Run `ember g ember-cli-yuidoc` to generate one.");
      process.exit(1);
    }

    if (exclusions.indexOf(config.options.exclude) === -1){
      exclusions.push(config.options.exclude)
    }

    var outDir = config.options.outdir || 'docs';

    var options = Y.Project.init({
      outdir: outDir,
      destDir: outDir,
      paths: config.options.paths || '.',
      version: getVersion(),
      external: config.external || config.options.external || {},
      yuidoc: {
        linkNatives: true,
        quiet: true,
        parseOnly: false,
        lint: false,
        exclude: exclusions.join(',')
      }
    });

    return options;
  }
}

'use strict';

var getVersion  = require('git-repo-version');
var fs          = require('fs');
var Y           = require('yuidocjs');

module.exports = {
  generate: function generateYuidocOptions(){
    var config;
    var exclusions = [
      '.DS_Store',
      '.git',
      'node_modules',
      'vendor',
      'bower_components',
      'tmp',
      'tests'
    ];

    try {
      config = JSON.parse(fs.readFileSync('yuidoc.json'));
    } catch(e){
      console.log("No yuidoc.json file in root folder. Run `ember g ember-cli-yuidoc` to generate one.");
      process.exit(1);
    }

    if (exclusions.indexOf(config.options.exclude) === -1){
      exclusions.push(config.options.exclude)
    }

    var outDir = config.options.outdir || 'docs';

    var options = Y.Project.init({
      outdir: outDir,
      destDir: outDir,
      paths: config.options.paths || '.',
      version: getVersion(),
      external: config.external || {},
      yuidoc: {
        linkNatives: true,
        quiet: true,
        parseOnly: false,
        lint: false,
        exclude: exclusions.join(',')
      }
    });

    return options;
  }
}

--- 
+++ 
@@ -35,7 +35,7 @@
       destDir: outDir,
       paths: config.options.paths || '.',
       version: getVersion(),
-      external: config.external || {},
+      external: config.external || config.options.external || {},
       yuidoc: {
         linkNatives: true,
         quiet: true,
Make addon lookup external data same as YUIDoc tool

YUIDoc tool and the addon will both find "external.data" at the top-level
of yuidoc.json, but unfortunately the YUIDoc documentation says it's
support to go in "options". The tool will find it here, but this addon
won't. This fixes that and makes the lookup order the same.
