'use strict';

var fs = require('fs');
var path = require('path');

/**
 * 获取generate-react目录下的模块名
 * （默认该目录下全为依赖模块）
 * 返回模块名数组
 */
function getSubmodule() {
  var components = [];
  var cmpsPath = path.join(process.cwd(), 'target', 'generate-react');
  var files = fs.readdirSync(cmpsPath);

  files.forEach(function (item) {
    var stat = fs.lstatSync('./target/generate-react/' + item);
    if (stat.isDirectory() === true
    // && !item.startsWith('hap-core')
    ) {
        components.push(item);
      }
  });

  return components;
}

module.exports = getSubmodule;