diff --git a/functions.sh b/functions.sh index 444dc2f67..cac81c387 100755 --- a/functions.sh +++ b/functions.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Utlity functions +# Utility functions # Don't change this file unless needed # The GitHub Action for automating new builds rely on this file @@ -19,7 +19,7 @@ fatal() { # # This is used to get the target architecture for docker image. # For crossing building, we need a way to specify the target -# architecutre manually. +# architecture manually. function get_arch() { local arch case $(uname -m) in diff --git a/genMatrix.js b/genMatrix.js index 1d592cca3..dc7672432 100644 --- a/genMatrix.js +++ b/genMatrix.js @@ -17,14 +17,14 @@ const getChildDirectories = (parent) => fs.readdirSync(parent, { withFileTypes: .filter((dirent) => dirent.isDirectory()) .map(({ name }) => path.resolve(parent, name)); -const getNodeVerionDirs = (base) => getChildDirectories(base) +const getNodeVersionDirs = (base) => getChildDirectories(base) .filter((childPath) => nodeDirRegex.test(path.basename(childPath))); // Returns the paths of Dockerfiles that are at: base/*/Dockerfile const getDockerfilesInChildDirs = (base) => getChildDirectories(base) .map((childDir) => path.resolve(childDir, 'Dockerfile')); -const getAllDockerfiles = (base) => getNodeVerionDirs(base).flatMap(getDockerfilesInChildDirs); +const getAllDockerfiles = (base) => getNodeVersionDirs(base).flatMap(getDockerfilesInChildDirs); const getAffectedDockerfiles = (filesAdded, filesModified, filesRenamed) => { const files = [ diff --git a/stackbrew.js b/stackbrew.js index 9e7c8eab1..9d82f310f 100755 --- a/stackbrew.js +++ b/stackbrew.js @@ -28,14 +28,13 @@ const versions = Object.keys(config).reverse() let midnight = new Date() midnight.setHours(0, 0, 0, 0) const now = midnight.getTime() -const aplineRE = new RegExp(/alpine*/); +const alpineRE = new RegExp(/alpine*/); const slimRE = new RegExp(/\*-slim/); let foundLTS = false; let foundCurrent = false; -for (version of versions) { +for (const version of versions) { let lts = new Date(`${config[version].lts}T00:00:00.00`).getTime(); - let maintenance = new Date(`${config[version].maintenance}T00:00:00.00`).getTime(); let isCurrent = foundCurrent ? false : isNaN(lts) || lts >= now; foundCurrent = isCurrent || foundCurrent; let isLTS = foundLTS ? false : (now >= lts); @@ -44,21 +43,20 @@ for (version of versions) { let defaultAlpine = config[version]['alpine-default'] let defaultDebian = config[version]['debian-default'] let variants = config[version].variants - let fullversion; - for (variant in variants) { + for (const variant in variants) { let dockerfilePath = path.join(version, variant, 'Dockerfile'); - let isAlpine = aplineRE.test(variant) + let isAlpine = alpineRE.test(variant) let isSlim = slimRE.test(variant) let isDefaultSlim = new RegExp(`${defaultDebian}-slim`).test(variant) // Get full version from the Dockerfile let dockerfile = fs.readFileSync(dockerfilePath, 'utf-8') - fullversion = dockerfile.match(/ENV NODE_VERSION=(?\d+)\.(?\d+)\.(?\d+)/) + let fullVersion = dockerfile.match(/ENV NODE_VERSION=(?\d+)\.(?\d+)\.(?\d+)/) let tags = [ - `${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-${variant}`, - `${fullversion.groups.major}.${fullversion.groups.minor}-${variant}`, - `${fullversion.groups.major}-${variant}`, + `${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-${variant}`, + `${fullVersion.groups.major}.${fullVersion.groups.minor}-${variant}`, + `${fullVersion.groups.major}-${variant}`, ] if (codename) { @@ -66,31 +64,31 @@ for (version of versions) { } if (variant === defaultAlpine) { - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-alpine`) - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-alpine`) - tags.push(`${fullversion.groups.major}-alpine`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-alpine`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-alpine`) + tags.push(`${fullVersion.groups.major}-alpine`) if (codename) { tags.push(`${codename}-alpine`) } } if (variant === defaultDebian) { - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}`) - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}`) - tags.push(`${fullversion.groups.major}`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}`) + tags.push(`${fullVersion.groups.major}`) if (isSlim) { - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-slim`) - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-slim`) - tags.push(`${fullversion.groups.major}-slim`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-slim`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-slim`) + tags.push(`${fullVersion.groups.major}-slim`) } if (codename) { tags.push(`${codename}`) } } if (isDefaultSlim) { - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-slim`) - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-slim`) - tags.push(`${fullversion.groups.major}-slim`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-slim`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-slim`) + tags.push(`${fullVersion.groups.major}-slim`) if (codename) { tags.push(`${codename}-slim`) } @@ -99,9 +97,9 @@ for (version of versions) { if (isCurrent) { if (variant === defaultAlpine) { tags.push(variant) - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}.${fullversion.groups.patch}-alpine`) - tags.push(`${fullversion.groups.major}.${fullversion.groups.minor}-alpine`) - tags.push(`${fullversion.groups.major}-alpine`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}.${fullVersion.groups.patch}-alpine`) + tags.push(`${fullVersion.groups.major}.${fullVersion.groups.minor}-alpine`) + tags.push(`${fullVersion.groups.major}-alpine`) tags.push('alpine') tags.push('current-alpine') } @@ -126,8 +124,6 @@ for (version of versions) { if (isLTS) { tags.push(`lts-${variant}`) - if (variant === defaultAlpine) { - } if (variant === defaultDebian) { tags.push('lts') if (codename) {