Returns a list of imports from the specified entry file

@param {string} dir - entry directory
@param {string} content - file content
@param {!Array} [arr]
@returns {!Array<string>}
184637
function getEntryImports(dir, content, arr = []) {
	$C(content.split(eol)).forEach((line) => {
		if (!hasImport.test(line)) {
			return;
		}

		const
			url = RegExp.$2,
			nodeModule = isNodeModule(url);

		if (nodeModule && entriesDir.test(url) || insideEntry.test(url)) {
			const
				d = nodeModule ? lib : dir;

			let
				f = path.join(d, `${url}.js`);

			if (!fs.existsSync(f)) {
				f = path.join(d, url, 'index.js');
			}

			getEntryImports(path.dirname(f), fs.readFileSync(f, 'utf-8'), arr);

		} else {
			arr.push(nodeModule ? url : path.join(dir, url));
		}
	});

	return arr;
}
459581
function getAllTasks(directories, options) {
	const allTasks = getAllAliases(options);
	for (const dir of directories) {
		const tasks = glob.sync(`${dir}/*/index.js`);
		tasks.forEach(filename => {
			const taskName = path.basename(path.dirname(filename));
			if (!allTasks[taskName]) {
				const module = require(filename);
				allTasks[taskName] = module.description || '';
			}
		});
	}
	return allTasks;
}
42743
def get_entries(path):
    """"""
    dirs, files = [], []
    for entry in os.listdir(path):
        # Categorize entry as directory or file.
        if os.path.isdir(os.path.join(path, entry)):
            dirs.append(entry)
        else:
            files.append(entry)
    dirs.sort()
    files.sort()
    return dirs, files
453861
function (dir, done) {
  var results = [];
  fs.readdir(dir, function (err, list) {
    if (err) return done(err);
    var i = 0;
    (function next() {
      var file = list[i++];
      if (!file) return done(null, results);
      file = dir + '/' + file;
      fs.stat(file, function (err2, stat) {
        if (stat && stat.isDirectory()) {
          walk(file, function (err3, res) {
            results = results.concat(res);
            next();
          });
        } else {
          results.push(file);
          next();
        }
      });
    })();
  });
}
431015
function _getFileContents(values) {
  const env = getDefaultSlateEnv();

  for (const key in values) {
    if (values.hasOwnProperty(key) && env.hasOwnProperty(key)) {
      env[key] = values[key];
    }
  }

  return Object.entries(env)
    .map((keyValues) => {
      return `${keyValues.join('=')}\r\n`;
    })
    .join('\r\n\r\n');
}
238902
function readDirs(dir, cb)  {
  // find top-level module dirs
  if (Array.isArray(dir)) {
    // dir is a list of paths
    readDirsParallel(dir, cb);
  } else {
    // dir is a single path value
    readDirAbs(dir, cb);
  }
}
771535
function ( files ) {
        files = files || [ ];

        var me = this;
        var nEntries = files.map( function ( file ) {
          return me.getFileDescriptor( file );
        } );

        //normalizeEntries = nEntries;
        return nEntries;
      }
740282
function getPackCardFiles(dir) {
  var cards = [],
    files = FS.readdirSync(dir);

  for (var i = 0; i < files.length; i++) {
    var fileName = files[i];

    if (Path.extname(fileName) === '.js') {
      cards.push(Path.basename(fileName, Path.extname(fileName)));
    }
  }

  return cards;
}
34680
function _readAllFiles(sDir = '', aWhitelist = []) {
  // read all files in current directory
  const aFiles = fs.readdirSync(sDir)

  // loop at all files
  const aContents = aFiles.reduce((aContents, sFileName) => {
    // get file stats
    const oFile = fs.statSync(`${sDir}/${sFileName}`)
    if (oFile.isDirectory()) {
      // append files of directory to list
      return aContents.concat(_readAllFiles(`${sDir}/${sFileName}`))
    }

    // append file content to list (if contained in whitelist)
    return aWhitelist.length === 0 || aWhitelist.indexOf(sFileName) !== -1
      ? aContents.concat(fs.readFileSync(`${sDir}/${sFileName}`, 'utf8'))
      : aContents
  }, [])

  return aContents
}
1354851
function transformFile(contents) {
        var $ = cheerio.load(contents.toString());
        var result = [];
        $(options.selector).each(function() {
            var element = $(this);
            var fileName = options.getFileName(element);
            result.push(fileName);
        });

        return result;
    }
622569
def get_entries(dir, subfolder)
      base = site.in_source_dir(dir, subfolder)
      return [] unless File.exist?(base)

      entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
      entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
    end
365478
function (files) {
  if (files.length === 1) {
    return { file: files[0] };
  } else {
    var contents = files.map(function (fname) {
      return '@import ' + JSON.stringify(fname) + ';';
    }).join('\n');

    return { contents: contents };
  }
}
15740
function getDepAsynScripts(arrFile,context){
    var existsMap = {};
    var output = [];
    while(arrFile.length){
        var file = arrFile.shift();
        if(existsMap[file]){
            continue;
        }
        var fileObj = context.fileIdMap[file];
        if(!fileObj){
            fis.log.warn('file[%s] is not in context.fileIdMap',file);
            continue;
        }
        output.push(fileObj);

        if(fileObj.requires){
            var arrRequires = fileObj.requires;
           if(!Array.isArray(arrRequires)){
                arrRequires = [arrRequires];
            }
            arrFile = arrFile.concat(arrRequires);
        }
    }

    return output; 
}
803199
function walkTree(dirPath) {
    let filesindir = [];
    return new Promise((res, rej) => {
        if (dirPath.match(/node_modules|.git|bower|LICENCE|tree.json/)) {
            rej([]);
        }

        const relative = `${dirPath}/`,
            readPath = dirPath === '.' ? ROOT + '/' : dirPath + '/';

        readdir(path.resolve(readPath))
            .then(files => {
                files.map(async(i) => {
                    let file;
                    if (fs.statSync(path.join(relative, i)).isDirectory()) {
                        file = {
                            name: i,
                            type: 'dir',
                            path: `${relative}${i}`,
                            files: {}
                        }
                    } else {
                        file = {
                            id: id,
                            name: i,
                            type: 'file',
                            path: `${relative}${i}`,
                            imports: [],
                            exports: []
                        }
                        AllFiles[id++] = file;
                    }
                    filesindir.push(file);
                })
                res(filesindir);
            })
            .catch(err => {
                console.error(err);
                rej([]);
            })
    })
}
1293099
function getModules(directory, logger, local) {
    logger(`Getting modules @ ${directory.path}`);
    if (directory.barrel) {
        // If theres a barrel then use that as it *should* contain descendant modules.
        logger(`Found existing barrel @ ${directory.barrel.path}`);
        return [directory.barrel];
    }
    const files = [].concat(directory.files);
    if (!local) {
        directory.directories.forEach((childDirectory) => {
            // Recurse.
            files.push(...getModules(childDirectory, logger, local));
        });
    }
    // Only return files that look like TypeScript modules.
    return files.filter((file) => file.name.match(utilities_1.isTypeScriptFile));
}
1130773
function listModulesInDirectory(modulesDir) {
    const log = debug('phantomas:modules');
    log('Getting the list of all modules in ' + modulesDir);

    // https://nodejs.org/api/fs.html#fs_fs_readdirsync_path_options
    var ls = fs.readdirSync(modulesDir),
        modules = [];

    ls.forEach(function(entry) {
        // First check whether an entry is a directory, than check if it contains a module file
        // https://nodejs.org/api/fs.html#fs_fs_existssync_path
        if (fs.existsSync(modulesDir + '/' + entry + '/' + entry + '.js')) {
            modules.push(entry);
        }
    });

    return modules.sort();
}
1173460
def filtered_entries
      return [] unless exists?

      @filtered_entries ||=
        Dir.chdir(directory) do
          entry_filter.filter(entries).reject do |f|
            path = collection_dir(f)
            File.directory?(path) || entry_filter.symlink?(f)
          end
        end
    end