package com.brilliance.isc.tool.compareviewpage;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.SuffixFileFilter;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FileScanner {

    public static Map<String, List<File>> filemap = new HashMap<>();

    public Map<String, List<File>> getTargetFiles() {
        // 通过配置读取文件
        // 通过FileConfig, transcode, sourceFolder 比较views
        SourceConfig.transcode.forEach((key, value) -> {
            List<File> keyfiles = (List<File>)FileUtils.listFiles(new File(SourceConfig.sourceFolder, key), new SuffixFileFilter(".vue"), DirectoryFileFilter.INSTANCE);
            filemap.put(key, keyfiles);
            List<File> valuefiles = (List<File>)FileUtils.listFiles(new File(SourceConfig.sourceFolder, value), new SuffixFileFilter(".vue"), DirectoryFileFilter.INSTANCE);
            filemap.put(value, valuefiles);
        });
        return filemap;
    }
}
