mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:33:33 +00:00 
			
		
		
		
	Run 'npm run build'
This commit is contained in:
		
							parent
							
								
									7d279e1d70
								
							
						
					
					
						commit
						57edf6c8ba
					
				
							
								
								
									
										20
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -71768,15 +71768,25 @@ function translateArchToDistUrl(arch) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
function parseNodeVersionFile(contents) {
 | 
			
		||||
    var _a;
 | 
			
		||||
    var _a, _b;
 | 
			
		||||
    let nodeVersion;
 | 
			
		||||
    const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
 | 
			
		||||
    const nodeVersion = (_a = found === null || found === void 0 ? void 0 : found.groups) === null || _a === void 0 ? void 0 : _a.version;
 | 
			
		||||
    if (nodeVersion) {
 | 
			
		||||
        return nodeVersion;
 | 
			
		||||
    nodeVersion = (_a = found === null || found === void 0 ? void 0 : found.groups) === null || _a === void 0 ? void 0 : _a.version;
 | 
			
		||||
    if (!nodeVersion) {
 | 
			
		||||
        try {
 | 
			
		||||
            // Try parsing the file as an NPM `package.json`
 | 
			
		||||
            // file.
 | 
			
		||||
            nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
 | 
			
		||||
            if (!nodeVersion)
 | 
			
		||||
                throw new Error();
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
            // In the case of an unknown format,
 | 
			
		||||
            // return as is and evaluate the version separately.
 | 
			
		||||
    return contents.trim();
 | 
			
		||||
            nodeVersion = contents.trim();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return nodeVersion;
 | 
			
		||||
}
 | 
			
		||||
exports.parseNodeVersionFile = parseNodeVersionFile;
 | 
			
		||||
function isLatestSyntax(versionSpec) {
 | 
			
		||||
 | 
			
		||||
@ -495,24 +495,26 @@ function translateArchToDistUrl(arch: string): string {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function parseNodeVersionFile(contents: string): string {
 | 
			
		||||
  let nodeVersion: string | undefined;
 | 
			
		||||
 | 
			
		||||
  const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
 | 
			
		||||
  nodeVersion = found?.groups?.version;
 | 
			
		||||
 | 
			
		||||
  if (!nodeVersion) {
 | 
			
		||||
    try {
 | 
			
		||||
      // Try parsing the file as an NPM `package.json`
 | 
			
		||||
      // file.
 | 
			
		||||
      nodeVersion = JSON.parse(contents).engines?.node;
 | 
			
		||||
 | 
			
		||||
      if (!nodeVersion) throw new Error();
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      // In the case of an unknown format,
 | 
			
		||||
      // return as is and evaluate the version separately.
 | 
			
		||||
  let nodeVersion = contents.trim();
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
    // Assume all content parseable as JSON is a valid,
 | 
			
		||||
    // NPM `package.json` file
 | 
			
		||||
    const packageJson = JSON.parse(contents);
 | 
			
		||||
    nodeVersion = packageJson.engines.node || nodeVersion;
 | 
			
		||||
 | 
			
		||||
    if (!nodeVersion) throw
 | 
			
		||||
  } catch (err) {
 | 
			
		||||
    // If not, assume it is a node version file
 | 
			
		||||
    const found = nodeVersion.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
 | 
			
		||||
    nodeVersion = found?.groups?.version || nodeVersion;
 | 
			
		||||
      nodeVersion = contents.trim();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return nodeVersion;
 | 
			
		||||
  return nodeVersion as string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function isLatestSyntax(versionSpec): boolean {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user