mirror of
https://github.com/actions/setup-python.git
synced 2025-01-19 06:31:42 +07:00
Readability improvement: Move CacheDistributor constructor params to readonly abstract fields of concrete cache implementations. Remove empty CacheDistributor constructor.
This commit is contained in:
parent
3b3e184171
commit
3efe843c7b
@ -10,10 +10,8 @@ export enum State {
|
|||||||
|
|
||||||
abstract class CacheDistributor {
|
abstract class CacheDistributor {
|
||||||
protected CACHE_KEY_PREFIX = 'setup-python';
|
protected CACHE_KEY_PREFIX = 'setup-python';
|
||||||
constructor(
|
protected abstract readonly packageManager: string;
|
||||||
protected packageManager: string,
|
protected abstract readonly cacheDependencyPath: string;
|
||||||
protected cacheDependencyPath: string
|
|
||||||
) {}
|
|
||||||
|
|
||||||
protected abstract getCacheGlobalDirectories(): Promise<string[]>;
|
protected abstract getCacheGlobalDirectories(): Promise<string[]>;
|
||||||
protected abstract computeKeys(): Promise<{
|
protected abstract computeKeys(): Promise<{
|
||||||
|
@ -12,12 +12,13 @@ import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
|
|||||||
|
|
||||||
class PipCache extends CacheDistributor {
|
class PipCache extends CacheDistributor {
|
||||||
private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
|
private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
|
||||||
|
protected readonly packageManager = 'pip';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private pythonVersion: string,
|
private pythonVersion: string,
|
||||||
cacheDependencyPath = '**/requirements.txt'
|
protected readonly cacheDependencyPath = '**/requirements.txt'
|
||||||
) {
|
) {
|
||||||
super('pip', cacheDependencyPath);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getCacheGlobalDirectories() {
|
protected async getCacheGlobalDirectories() {
|
||||||
|
@ -6,11 +6,13 @@ import * as core from '@actions/core';
|
|||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
|
|
||||||
class PipenvCache extends CacheDistributor {
|
class PipenvCache extends CacheDistributor {
|
||||||
|
protected readonly packageManager = 'pipenv';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private pythonVersion: string,
|
private pythonVersion: string,
|
||||||
protected cacheDependencyPath: string = '**/Pipfile.lock'
|
protected readonly cacheDependencyPath: string = '**/Pipfile.lock'
|
||||||
) {
|
) {
|
||||||
super('pipenv', cacheDependencyPath);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getCacheGlobalDirectories() {
|
protected async getCacheGlobalDirectories() {
|
||||||
|
@ -8,12 +8,15 @@ import CacheDistributor from './cache-distributor';
|
|||||||
import {logWarning} from '../utils';
|
import {logWarning} from '../utils';
|
||||||
|
|
||||||
class PoetryCache extends CacheDistributor {
|
class PoetryCache extends CacheDistributor {
|
||||||
|
protected readonly packageManager = 'poetry';
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private pythonVersion: string,
|
private pythonVersion: string,
|
||||||
protected cacheDependencyPath: string = '**/poetry.lock',
|
protected readonly cacheDependencyPath: string = '**/poetry.lock',
|
||||||
protected poetryProjects: Set<string> = new Set<string>()
|
protected poetryProjects: Set<string> = new Set<string>()
|
||||||
) {
|
) {
|
||||||
super('poetry', cacheDependencyPath);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getCacheGlobalDirectories() {
|
protected async getCacheGlobalDirectories() {
|
||||||
|
Loading…
Reference in New Issue
Block a user