mirror of
				https://github.com/actions/setup-node.git
				synced 2025-10-31 16:14:00 +08:00 
			
		
		
		
	Add and configure ESLint and update configuration for Prettier (#703)
* Add ESLinter and update Prettier * Update eslint config * Update dependencies * Rebuild action * Update package.json * Updates docs * Update docs
This commit is contained in:
		| @@ -33,7 +33,7 @@ function writeRegistryToFile( | ||||
|   } | ||||
|  | ||||
|   core.debug(`Setting auth in ${fileLocation}`); | ||||
|   let newContents: string = ''; | ||||
|   let newContents = ''; | ||||
|   if (fs.existsSync(fileLocation)) { | ||||
|     const curContents: string = fs.readFileSync(fileLocation, 'utf8'); | ||||
|     curContents.split(os.EOL).forEach((line: string) => { | ||||
| @@ -46,8 +46,8 @@ function writeRegistryToFile( | ||||
|   // Remove http: or https: from front of registry. | ||||
|   const authString: string = | ||||
|     registryUrl.replace(/(^\w+:|^)/, '') + ':_authToken=${NODE_AUTH_TOKEN}'; | ||||
|   const registryString: string = `${scope}registry=${registryUrl}`; | ||||
|   const alwaysAuthString: string = `always-auth=${alwaysAuth}`; | ||||
|   const registryString = `${scope}registry=${registryUrl}`; | ||||
|   const alwaysAuthString = `always-auth=${alwaysAuth}`; | ||||
|   newContents += `${authString}${os.EOL}${registryString}${os.EOL}${alwaysAuthString}`; | ||||
|   fs.writeFileSync(fileLocation, newContents); | ||||
|   core.exportVariable('NPM_CONFIG_USERCONFIG', fileLocation); | ||||
|   | ||||
| @@ -54,7 +54,7 @@ export const restoreCache = async ( | ||||
| }; | ||||
|  | ||||
| const findLockFile = (packageManager: PackageManagerInfo) => { | ||||
|   let lockFiles = packageManager.lockFilePatterns; | ||||
|   const lockFiles = packageManager.lockFilePatterns; | ||||
|   const workspace = process.env.GITHUB_WORKSPACE!; | ||||
|   const rootContent = fs.readdirSync(workspace); | ||||
|  | ||||
|   | ||||
| @@ -70,7 +70,7 @@ export default abstract class BaseDistribution { | ||||
|  | ||||
|     core.debug(`evaluating ${versions.length} versions`); | ||||
|  | ||||
|     for (let potential of versions) { | ||||
|     for (const potential of versions) { | ||||
|       const satisfied: boolean = semver.satisfies(potential, range, options); | ||||
|       if (satisfied) { | ||||
|         version = potential; | ||||
| @@ -95,18 +95,18 @@ export default abstract class BaseDistribution { | ||||
|     const initialUrl = this.getDistributionUrl(); | ||||
|     const dataUrl = `${initialUrl}/index.json`; | ||||
|  | ||||
|     let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl); | ||||
|     const response = await this.httpClient.getJson<INodeVersion[]>(dataUrl); | ||||
|     return response.result || []; | ||||
|   } | ||||
|  | ||||
|   protected getNodejsDistInfo(version: string) { | ||||
|     let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch); | ||||
|     const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch); | ||||
|     version = semver.clean(version) || ''; | ||||
|     let fileName: string = | ||||
|     const fileName: string = | ||||
|       this.osPlat == 'win32' | ||||
|         ? `node-v${version}-win-${osArch}` | ||||
|         : `node-v${version}-${this.osPlat}-${osArch}`; | ||||
|     let urlFileName: string = | ||||
|     const urlFileName: string = | ||||
|       this.osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`; | ||||
|     const initialUrl = this.getDistributionUrl(); | ||||
|     const url = `${initialUrl}/v${version}/${urlFileName}`; | ||||
| @@ -137,7 +137,7 @@ export default abstract class BaseDistribution { | ||||
|       throw err; | ||||
|     } | ||||
|  | ||||
|     let toolPath = await this.extractArchive(downloadPath, info); | ||||
|     const toolPath = await this.extractArchive(downloadPath, info); | ||||
|     core.info('Done'); | ||||
|  | ||||
|     return toolPath; | ||||
| @@ -156,7 +156,7 @@ export default abstract class BaseDistribution { | ||||
|     arch: string = os.arch() | ||||
|   ): Promise<string> { | ||||
|     const initialUrl = this.getDistributionUrl(); | ||||
|     let osArch: string = this.translateArchToDistUrl(arch); | ||||
|     const osArch: string = this.translateArchToDistUrl(arch); | ||||
|  | ||||
|     // Create temporary folder to download in to | ||||
|     const tempDownloadFolder: string = | ||||
| @@ -240,7 +240,7 @@ export default abstract class BaseDistribution { | ||||
|   } | ||||
|  | ||||
|   protected getDistFileName(): string { | ||||
|     let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch); | ||||
|     const osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch); | ||||
|  | ||||
|     // node offers a json list of versions | ||||
|     let dataFileName: string; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ivan
					Ivan