public static JsFile GetJsFile(string filePath, Dictionary <string, JsFile> dic, string importStr)
        {
            var fileInfo = new FileInfo(GetJsFileAbsFullName(filePath));

            if (!dic.ContainsKey(fileInfo.FullName))
            {
                var f = new JsFile();
                f.FileImportStr  = importStr;
                f.ResolveAbsPath = fileInfo.FullName;
                f.FileName       = fileInfo.Name;
                f.FileRealName   = fileInfo.Name.Substring(0, fileInfo.Name.LastIndexOf('.'));
                f.FileExtName    = fileInfo.Name.Substring(f.FileRealName.Length);
                f.FilePath       = fileInfo.DirectoryName + @"\";
                f.IsUserFile     = true;
                f.ImportStatus   = JsFileImportStatus.ImportNone;
                f.AddToDic(dic);
                var content = f.ReadFileString(f.ResolveAbsPath);
                f.ImportStrings = f.GetImportString(content);
                f.Imports       = new List <ImportStruct>();
                if (f.ImportStrings.Count == 0)
                {
                    f.ImportStatus = JsFileImportStatus.ImportComplete;
                }
                return(f);
            }
            else
            {
                return(dic[fileInfo.FullName]);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            dia.ShowDialog();
            if (!File.Exists(dia.FileName))
            {
                MessageBox.Show("必须选择文件");
                return;
            }
            ReadFileString(dia.FileName);
            FileInfo fileInfo = new FileInfo(dia.FileName);

            jsFileBasePath  = fileInfo.DirectoryName + @"\";
            packageJsonPath = jsFileBasePath;
            while (!File.Exists(packageJsonPath + @"\package.json"))
            {
                packageJsonPath += @"..\";
            }
            packageJsonPath = new DirectoryInfo(packageJsonPath).FullName;
            DicNameToJsFile = new Dictionary <string, JsFile>();

            var mainFile = JsFile.GetJsFile(dia.FileName, DicNameToJsFile, fileInfo.Name);

            mainFile.Resolve(DicNameToJsFile);

            var str = mainFile.ToJson(ES6ImportModuleAnalyse.JsFile.JsFileImportStatus.Importing);

            textBox1.Text = str;

            addTreeHead(Common.JsonToDictionary(str));

            var allJsFiles = GetAllFile(packageJsonPath);

            //var package_json = Common.JsonToDictionary(ReadFileString(dia.FileName));
            //var cmd_npm_start_str = package_json.GetString(new string[] { "scripts", "start" });
            //var webpack_config_js_reg = new Regex(@"--config\s+(?<webpackConfig>.+)\s*");
            //var webpack_config_js_group = webpack_config_js_reg.Match(cmd_npm_start_str).Groups;
            //var webpack_config_js_str = webpack_config_js_group["webpackConfig"].ToString();
        }
 public ImportStruct(JsFile f, ES6ImportModuleAnalyse.JsFile.JsFileImportStatus status)
 {
     this.file       = f;
     this.filePath   = f.ResolveAbsPath;
     this.fileStatus = status;
 }