Example #1
0
        protected virtual async Task <PackagePathSegments> ResolveVersion(PackagePathSegments pps)
        {
            var package = pps.Package;
            var version = pps.Version;


            // replace version... if it is empty
            if (string.IsNullOrWhiteSpace(version))
            {
                // find from version provider..
                if (versionProvider != null)
                {
                    version = await versionProvider(services, pps);
                }
                if (string.IsNullOrWhiteSpace(version))
                {
                    var existing = this.privatePackages.FirstOrDefault(x => x.Package == package);
                    if (existing != null)
                    {
                        version = existing.Version;
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(version))
            {
                pps.Version = version;
            }

            return(pps);
        }
 public PackagePath(
     PackageInstallerOptions options,
     PackagePathSegments p,
     bool isPrivate)
 {
     this.Options   = options;
     this.isPrivate = isPrivate;
     this.Package   = p.Package;
     this.Version   = p.Version;
     this.Path      = p.Path;
 }
Example #3
0
        public async Task <NodeInstalledPackage> InstalledPackageAsync(string path)
        {
            PackagePathSegments pps = path;

            pps = await this.ResolveVersion(pps);

            var pp = new PackagePath(this.Options, pps, true);

            return(await cache.GetAsync(pp.Package + "@" + pp.Version, async entry => {
                entry.SlidingExpiration = this.Options.TTL;

                await InstallAsync(pp);
                var p = CreatePackage(pp);
                entry.EvictionCallbacks.Add((a) => {
                    p.Dispose();
                });
                return p;
            }));
        }