packages/swig-install/lib/public-directory.js
function compile() {
    swig.log.info('', 'Compiling module list...');

    const modulesPath = path.join(swig.temp, '/**/node_modules/@gilt-tech');
    const modPaths = glob.sync(modulesPath);
    let dirs;

    swig.log.verbose(`[compile] searching: ${modulesPath}`);
    swig.log.verbose(`[compile] found module directories: ${modPaths.length}`);

    modPaths.forEach((modPath) => {
      swig.log.verbose(`[compile] compiling: ${modPath}`);

      dirs = fs.readdirSync(modPath);

      _.each(dirs, (dir) => {
        const dirPath = path.join(modPath, dir);
        if (fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory()) {
          azModules.push({ name: dir, path: dirPath });
        }
      });
    });

    // group by basename, and take the 'topmost' module in the hierarchy
    azModules = _.groupBy(azModules, module => path.basename(module.path));

    // pull out the 'winning' module path, for each module
    azModules = _.map(azModules, (modulesList) => {
      // the modules arg will be [{ name:, path: }, ...]

      if (modulesList.length === 1) {
        return modulesList[0];
      }

      // glob will almost always return the right order,
      // but let's assert this to be safe. we can spare the cycles.
      return _.sortBy(modulesList, module => module.path.length)[0];
    });

    // and now we pretty sort a-z for various output
    // we dont reset azModules to the sorted array because we need it dirty for deps.less
    _.sortBy(azModules, mod => mod.name).forEach((mod) => {
      modules[mod.name] = mod.path;
    });

    swig.log.verbose('[compile] sorted modules: ');
    swig.log.verbose(modules);
  }
function compile() {
    swig.log.info('', 'Compiling module list...');

    const modulesPath = path.join(swig.temp, '/**/node_modules/@gilt-tech');
    const modPaths = glob.sync(modulesPath);
    let dirs;

    swig.log.verbose(`[compile] searching: ${modulesPath}`);
    swig.log.verbose(`[compile] found module directories: ${modPaths.length}`);

    modPaths.forEach((modPath) => {
      swig.log.verbose(`[compile] compiling: ${modPath}`);

      dirs = fs.readdirSync(modPath);

      _.each(dirs, (dir) => {
        const dirPath = path.join(modPath, dir);
        if (fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory()) {
          azModules.push({ name: dir, path: dirPath });
        }
      });
    });

    // group by basename, and take the 'topmost' module in the hierarchy
    azModules = _.groupBy(azModules, module => path.basename(module.path));

    // pull out the 'winning' module path, for each module
    azModules = _.map(azModules, (modulesList) => {
      // the modules arg will be [{ name:, path: }, ...]

      if (modulesList.length === 1) {
        return modulesList[0];
      }

      // glob will almost always return the right order,
      // but let's assert this to be safe. we can spare the cycles.
      return _.sortBy(modulesList, module => module.path.length)[0];
    });

    // and now we pretty sort a-z for various output
    // we dont reset azModules to the sorted array because we need it dirty for deps.less
    _.sortBy(azModules, mod => mod.name).forEach((mod) => {
      modules[mod.name] = mod.path;
    });

    swig.log.verbose('[compile] sorted modules: ');
    swig.log.verbose(modules);
  }
function compile ( ) { swig . log . info ( '' , 'Compiling module list...' ) ; const modulesPath = path . join ( swig . temp , '/**/node_modules/@gilt-tech' ) ; const modPaths = glob . sync ( modulesPath ) ; let dirs ; swig . log . verbose ( ` ${ modulesPath } ` ) ; swig . log . verbose ( ` ${ modPaths . length } ` ) ; modPaths . forEach ( ( modPath ) => { swig . log . verbose ( ` ${ modPath } ` ) ; dirs = fs . readdirSync ( modPath ) ; _ . each ( dirs , ( dir ) => { const dirPath = path . join ( modPath , dir ) ; if ( fs . existsSync ( dirPath ) && fs . lstatSync ( dirPath ) . isDirectory ( ) ) { azModules . push ( { name : dir , path : dirPath } ) ; } } ) ; } ) ; // group by basename, and take the 'topmost' module in the hierarchy azModules = _ . groupBy ( azModules , module => path . basename ( module . path ) ) ; // pull out the 'winning' module path, for each module azModules = _ . map ( azModules , ( modulesList ) => { // the modules arg will be [{ name:, path: }, ...] if ( modulesList . length === 1 ) { return modulesList [ 0 ] ; } // glob will almost always return the right order, // but let's assert this to be safe. we can spare the cycles. return _ . sortBy ( modulesList , module => module . path . length ) [ 0 ] ; } ) ; // and now we pretty sort a-z for various output // we dont reset azModules to the sorted array because we need it dirty for deps.less _ . sortBy ( azModules , mod => mod . name ) . forEach ( ( mod ) => { modules [ mod . name ] = mod . path ; } ) ; swig . log . verbose ( '[compile] sorted modules: ' ) ; swig . log . verbose ( modules ) ; }
find and compile a list of all unique modules, and their paths
find and compile a list of all unique modules and their paths