Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply stricter linting #24

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ env:
node: true
es2021: true
extends:
- google
- airbnb
parserOptions:
ecmaVersion: 12
rules: {
indent: ["warn", 2],
max-len: ["warn", 100],
no-console: 0,
no-undef: "error",
no-unused-vars: ["error", {"varsIgnorePattern": "^_"}],
no-use-before-define: 0,
operator-linebreak: 0,
require-jsdoc: 0,
semi: 0,
no-undef: "error"
semi: 0
}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"arrowParens": "always",
"bracketSpacing": false,
"bracketSpacing": true,
"semi": false,
"singleQuote": true,
"trailingComma": "all"
Expand Down
455 changes: 254 additions & 201 deletions 3RD_PARTY_LICENSES

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __tests__/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ simulateInput('rebar3-version', '3.14')
simulateInput('install-rebar', 'true')
simulateInput('install-hex', 'true')

const setupElixir = require('../src/setup-beam')
const assert = require('assert')
const setupElixir = require('../src/setup-beam')
const installer = require('../src/installer')

async function all() {
Expand Down
62 changes: 30 additions & 32 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4555,7 +4555,7 @@ try {
/***/ 2127:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const {exec} = __nccwpck_require__(1514)
const { exec } = __nccwpck_require__(1514)
const path = __nccwpck_require__(5622)

/**
Expand Down Expand Up @@ -4593,10 +4593,10 @@ function checkPlatform() {
}

module.exports = {
installOTP: installOTP,
installElixir: installElixir,
installRebar3: installRebar3,
checkPlatform: checkPlatform,
installOTP,
installElixir,
installRebar3,
checkPlatform,
}


Expand All @@ -4606,11 +4606,11 @@ module.exports = {
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const core = __nccwpck_require__(2186)
const {exec} = __nccwpck_require__(1514)
const installer = __nccwpck_require__(2127)
const { exec } = __nccwpck_require__(1514)
const path = __nccwpck_require__(5622)
const semver = __nccwpck_require__(1383)
const https = __nccwpck_require__(7211)
const installer = __nccwpck_require__(2127)

main().catch((err) => {
core.setFailed(err.message)
Expand All @@ -4620,10 +4620,10 @@ async function main() {
installer.checkPlatform()

const osVersion = getRunnerOSVersion()
const otpSpec = core.getInput('otp-version', {required: true})
const otpSpec = core.getInput('otp-version', { required: true })
const otpVersion = await installOTP(otpSpec, osVersion)

const elixirSpec = core.getInput('elixir-version', {required: false})
const elixirSpec = core.getInput('elixir-version', { required: false })
const elixirInstalled = await maybeInstallElixir(elixirSpec, otpVersion)
if (elixirInstalled === true) {
const shouldMixRebar = core.getInput('install-rebar', {
Expand All @@ -4636,7 +4636,7 @@ async function main() {
await mix(shouldMixHex, 'hex')
}

const rebar3Spec = core.getInput('rebar3-version', {required: false})
const rebar3Spec = core.getInput('rebar3-version', { required: false })
maybeInstallRebar3(rebar3Spec)
}

Expand All @@ -4648,7 +4648,7 @@ async function installOTP(otpSpec, osVersion) {
await installer.installOTP(osVersion, otpVersion)
core.setOutput('otp-version', otpVersion)
prependToPath(`${process.env.RUNNER_TEMP}/.setup-beam/otp/bin`)
console.log(`##[endgroup]`)
console.log('##[endgroup]')

return otpVersion
}
Expand All @@ -4662,12 +4662,12 @@ async function maybeInstallElixir(elixirSpec, otpVersion) {
const matchersPath = __nccwpck_require__.ab + ".github"
console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
prependToPath(`${process.env.RUNNER_TEMP}/.setup-beam/elixir/bin`)
console.log(`##[endgroup]`)
console.log('##[endgroup]')

return true
} else {
return false
}

return false
}

async function mix(shouldMix, what) {
Expand All @@ -4676,7 +4676,7 @@ async function mix(shouldMix, what) {
const args = [`local.${what}`, '--force']
console.log(`##[group]Running ${cmd} ${args}`)
await exec(cmd, args)
console.log(`##[endgroup]`)
console.log('##[endgroup]')
}
}

Expand All @@ -4687,12 +4687,12 @@ async function maybeInstallRebar3(rebar3Spec) {
await installer.installRebar3(rebar3Version)
core.setOutput('rebar3-version', rebar3Version)
prependToPath(`${process.env.RUNNER_TEMP}/.setup-beam/rebar3/bin`)
console.log(`##[endgroup]`)
console.log('##[endgroup]')

return true
} else {
return false
}

return false
}

async function getOTPVersion(otpSpec0, osVersion) {
Expand All @@ -4702,7 +4702,7 @@ async function getOTPVersion(otpSpec0, osVersion) {
if (otpSpec[1]) {
throw new Error(
`Requested Erlang/OTP version (from spec ${otpSpec0}) ` +
`should not contain 'OTP-'`,
"should not contain 'OTP-'",
)
}
if (otpSpec) {
Expand All @@ -4729,7 +4729,7 @@ async function getElixirVersion(exSpec0, otpVersion) {
if (exSpec[2]) {
throw new Error(
`Requested Elixir / Erlang/OTP version (from spec ${exSpec0} / ${otpVersion}) ` +
`should not contain '-otp-...'`,
"should not contain '-otp-...'",
)
}
if (exSpec) {
Expand All @@ -4740,15 +4740,15 @@ async function getElixirVersion(exSpec0, otpVersion) {
`Requested Elixir version (from spec ${exSpec0}) not found in build listing`,
)
}
const otpMatch = otpVersion.match(/^(?:OTP-)?([^\.]+)/)
const otpMatch = otpVersion.match(/^(?:OTP-)?([^.]+)/)
let elixirVersionWithOTP

if (elixirVersions.get(elixirVersion)) {
const otpVersionMajor = otpMatch[1]
// We try for a version like `v1.4.5-otp-20`...
if (elixirVersions.get(elixirVersion).includes(otpMatch[1])) {
// ... and it's available: use it!
elixirVersionWithOTP = elixirVersion + `-otp-${otpVersionMajor}`
elixirVersionWithOTP = `${elixirVersion}-otp-${otpVersionMajor}`
core.info(`Using Elixir / -otp- version ${elixirVersionWithOTP}`)
} else {
// ... and it's not available: fallback to the "generic" version (v1.4.5 only).
Expand All @@ -4758,7 +4758,7 @@ async function getElixirVersion(exSpec0, otpVersion) {
} else {
throw new Error(
`Requested Elixir / Erlang/OTP version (from spec ${exSpec0} / ${otpVersion}) not ` +
`found in build listing`,
'found in build listing',
)
}

Expand Down Expand Up @@ -4786,14 +4786,12 @@ async function getOTPVersions(osVersion) {
otpVersionsListing
.trim()
.split('\n')
.map((line) => {
debugger
.forEach((line) => {
const otpMatch = line.match(/^(OTP-)?([^ ]+)/)

const otpVersion = otpMatch[2]
otpVersions.set(otpVersion, otpMatch[0]) // we keep the original for later reference
})
.sort()

return otpVersions
}
Expand Down Expand Up @@ -4837,9 +4835,9 @@ async function getRebar3Versions() {
function getVersionFromSpec(spec, versions) {
if (versions.includes(spec)) {
return spec
} else {
return semver.maxSatisfying(versions, semver.validRange(spec))
}

return semver.maxSatisfying(versions, semver.validRange(spec))
}

function getRunnerOSVersion() {
Expand All @@ -4858,7 +4856,7 @@ function get(url) {
.get(
url,
{
headers: {'user-agent': 'setup-beam'},
headers: { 'user-agent': 'setup-beam' },
},
(res) => {
let data = ''
Expand All @@ -4881,9 +4879,9 @@ function prependToPath(what) {
}

module.exports = {
getOTPVersion: getOTPVersion,
getElixirVersion: getElixirVersion,
getRebar3Version: getRebar3Version,
getOTPVersion,
getElixirVersion,
getRebar3Version,
}


Expand Down
Loading