mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 12:13:35 +00:00 
			
		
		
		
	simplify code
This commit is contained in:
		
							parent
							
								
									8dfba60365
								
							
						
					
					
						commit
						166e53bba8
					
				
							
								
								
									
										59
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										59
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -73849,74 +73849,19 @@ exports["default"] = RcBuild;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
"use strict";
 | 
					"use strict";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
 | 
					 | 
				
			||||||
    if (k2 === undefined) k2 = k;
 | 
					 | 
				
			||||||
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
 | 
					 | 
				
			||||||
}) : (function(o, m, k, k2) {
 | 
					 | 
				
			||||||
    if (k2 === undefined) k2 = k;
 | 
					 | 
				
			||||||
    o[k2] = m[k];
 | 
					 | 
				
			||||||
}));
 | 
					 | 
				
			||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
 | 
					 | 
				
			||||||
    Object.defineProperty(o, "default", { enumerable: true, value: v });
 | 
					 | 
				
			||||||
}) : function(o, v) {
 | 
					 | 
				
			||||||
    o["default"] = v;
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
var __importStar = (this && this.__importStar) || function (mod) {
 | 
					 | 
				
			||||||
    if (mod && mod.__esModule) return mod;
 | 
					 | 
				
			||||||
    var result = {};
 | 
					 | 
				
			||||||
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 | 
					 | 
				
			||||||
    __setModuleDefault(result, mod);
 | 
					 | 
				
			||||||
    return result;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
					var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
				
			||||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
					    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
					Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
				
			||||||
const tc = __importStar(__nccwpck_require__(7784));
 | 
					const nightly_builds_1 = __importDefault(__nccwpck_require__(7127));
 | 
				
			||||||
const semver_1 = __importDefault(__nccwpck_require__(5911));
 | 
					class CanaryBuild extends nightly_builds_1.default {
 | 
				
			||||||
const base_distribution_1 = __importDefault(__nccwpck_require__(7));
 | 
					 | 
				
			||||||
class CanaryBuild extends base_distribution_1.default {
 | 
					 | 
				
			||||||
    constructor(nodeInfo) {
 | 
					    constructor(nodeInfo) {
 | 
				
			||||||
        super(nodeInfo);
 | 
					        super(nodeInfo);
 | 
				
			||||||
        this.distribution = 'v8-canary';
 | 
					        this.distribution = 'v8-canary';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    findVersionInHostedToolCacheDirectory() {
 | 
					 | 
				
			||||||
        let toolPath = '';
 | 
					 | 
				
			||||||
        const localVersionPaths = tc
 | 
					 | 
				
			||||||
            .findAllVersions('node', this.nodeInfo.arch)
 | 
					 | 
				
			||||||
            .filter(i => {
 | 
					 | 
				
			||||||
            const prerelease = semver_1.default.prerelease(i);
 | 
					 | 
				
			||||||
            if (!prerelease) {
 | 
					 | 
				
			||||||
                return false;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return prerelease[0].includes(this.distribution);
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        localVersionPaths.sort(semver_1.default.rcompare);
 | 
					 | 
				
			||||||
        const localVersion = this.evaluateVersions(localVersionPaths);
 | 
					 | 
				
			||||||
        if (localVersion) {
 | 
					 | 
				
			||||||
            toolPath = tc.find('node', localVersion, this.nodeInfo.arch);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return toolPath;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    getDistributionUrl() {
 | 
					    getDistributionUrl() {
 | 
				
			||||||
        return 'https://nodejs.org/download/v8-canary';
 | 
					        return 'https://nodejs.org/download/v8-canary';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    validRange(versionSpec) {
 | 
					 | 
				
			||||||
        let range;
 | 
					 | 
				
			||||||
        const [raw, prerelease] = this.splitVersionSpec(versionSpec);
 | 
					 | 
				
			||||||
        const isValidVersion = semver_1.default.valid(raw);
 | 
					 | 
				
			||||||
        const rawVersion = (isValidVersion ? raw : semver_1.default.coerce(raw));
 | 
					 | 
				
			||||||
        if (prerelease !== this.distribution) {
 | 
					 | 
				
			||||||
            range = versionSpec;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            range = `${semver_1.default.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return { range, options: { includePrerelease: !isValidVersion } };
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    splitVersionSpec(versionSpec) {
 | 
					 | 
				
			||||||
        return versionSpec.split(/-(.*)/s);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports["default"] = CanaryBuild;
 | 
					exports["default"] = CanaryBuild;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,57 +1,13 @@
 | 
				
			|||||||
import * as tc from '@actions/tool-cache';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import semver from 'semver';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import BaseDistribution from '../base-distribution';
 | 
					 | 
				
			||||||
import {INodejs} from '../base-models';
 | 
					import {INodejs} from '../base-models';
 | 
				
			||||||
 | 
					import NightlyNodejs from '../nightly/nightly_builds';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class CanaryBuild extends BaseDistribution {
 | 
					export default class CanaryBuild extends NightlyNodejs {
 | 
				
			||||||
  protected distribution = 'v8-canary';
 | 
					 | 
				
			||||||
  constructor(nodeInfo: INodejs) {
 | 
					  constructor(nodeInfo: INodejs) {
 | 
				
			||||||
    super(nodeInfo);
 | 
					    super(nodeInfo);
 | 
				
			||||||
  }
 | 
					    this.distribution = 'v8-canary';
 | 
				
			||||||
 | 
					 | 
				
			||||||
  protected findVersionInHostedToolCacheDirectory(): string {
 | 
					 | 
				
			||||||
    let toolPath = '';
 | 
					 | 
				
			||||||
    const localVersionPaths = tc
 | 
					 | 
				
			||||||
      .findAllVersions('node', this.nodeInfo.arch)
 | 
					 | 
				
			||||||
      .filter(i => {
 | 
					 | 
				
			||||||
        const prerelease = semver.prerelease(i);
 | 
					 | 
				
			||||||
        if (!prerelease) {
 | 
					 | 
				
			||||||
          return false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return prerelease[0].includes(this.distribution);
 | 
					 | 
				
			||||||
      });
 | 
					 | 
				
			||||||
    localVersionPaths.sort(semver.rcompare);
 | 
					 | 
				
			||||||
    const localVersion = this.evaluateVersions(localVersionPaths);
 | 
					 | 
				
			||||||
    if (localVersion) {
 | 
					 | 
				
			||||||
      toolPath = tc.find('node', localVersion, this.nodeInfo.arch);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return toolPath;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  protected getDistributionUrl(): string {
 | 
					  protected getDistributionUrl(): string {
 | 
				
			||||||
    return 'https://nodejs.org/download/v8-canary';
 | 
					    return 'https://nodejs.org/download/v8-canary';
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  protected validRange(versionSpec: string) {
 | 
					 | 
				
			||||||
    let range: string;
 | 
					 | 
				
			||||||
    const [raw, prerelease] = this.splitVersionSpec(versionSpec);
 | 
					 | 
				
			||||||
    const isValidVersion = semver.valid(raw);
 | 
					 | 
				
			||||||
    const rawVersion = (isValidVersion ? raw : semver.coerce(raw))!;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (prerelease !== this.distribution) {
 | 
					 | 
				
			||||||
      range = versionSpec;
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      range = `${semver.validRange(`^${rawVersion}-${this.distribution}`)}-0`;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return {range, options: {includePrerelease: !isValidVersion}};
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  protected splitVersionSpec(versionSpec: string) {
 | 
					 | 
				
			||||||
    return versionSpec.split(/-(.*)/s);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user