Пример #1
0
        private PackageData GetPackageDataFromFolder([CanBeNull] string id,
                                                     [NotNull] FileSystemPath packageFolder,
                                                     PackageSource packageSource,
                                                     [CanBeNull] GitDetails gitDetails          = null,
                                                     [CanBeNull] FileSystemPath tarballLocation = null)
        {
            if (packageFolder.ExistsDirectory)
            {
                var packageJsonFile = packageFolder.Combine("package.json");
                if (packageJsonFile.ExistsFile)
                {
                    try
                    {
                        var packageJson    = PackageJson.FromJson(packageJsonFile.ReadAllText2().Text);
                        var packageDetails = PackageDetails.FromPackageJson(packageJson, packageFolder);
                        return(new PackageData(id ?? packageDetails.CanonicalName, packageFolder,
                                               packageJsonFile.FileModificationTimeUtc, packageDetails, packageSource, gitDetails,
                                               tarballLocation));
                    }
                    catch (Exception e)
                    {
                        myLogger.LogExceptionSilently(e);
                        return(null);
                    }
                }
            }

            return(null);
        }
Пример #2
0
 public PackageData([NotNull] string id,
                    [CanBeNull] FileSystemPath packageFolder,
                    DateTime packageJsonTimestamp,
                    PackageDetails packageDetails,
                    PackageSource source,
                    [CanBeNull] GitDetails gitDetails,
                    [CanBeNull] FileSystemPath tarballLocation)
 {
     Id                   = id;
     PackageFolder        = packageFolder;
     PackageJsonTimestamp = packageJsonTimestamp;
     PackageDetails       = packageDetails;
     Source               = source;
     GitDetails           = gitDetails;
     TarballLocation      = tarballLocation;
 }