diff --git a/src/lib/docker.js b/src/lib/docker.js index c177ded..3869831 100644 --- a/src/lib/docker.js +++ b/src/lib/docker.js @@ -1,14 +1,13 @@ import Regex from './regex.js' -import path from 'path' -import fs from 'fs' -import core from '@actions/core' +import { join } from 'path' +import { statSync } from 'fs' export default class Dockerfile extends Regex { constructor (root = null) { - root = path.join(process.env.GITHUB_WORKSPACE, root) + root = join(process.env.GITHUB_WORKSPACE, root) - if (fs.statSync(root).isDirectory()) { - root = path.join(root, 'Dockerfile') + if (statSync(root).isDirectory()) { + root = join(root, 'Dockerfile') } super(root, /LABEL[\s\t]+version=[\t\s+]?[\"\']?([0-9\.]+)[\"\']?/i) diff --git a/src/lib/regex.js b/src/lib/regex.js index 95557fb..08b5e59 100644 --- a/src/lib/regex.js +++ b/src/lib/regex.js @@ -1,19 +1,19 @@ -import fs from 'fs' -import path from 'path' +import { statSync, readFileSync } from 'fs' +import { resolve } from 'path' export default class Regex { constructor (root = './', pattern) { - root = path.resolve(root) + root = resolve(root) - if (fs.statSync(root).isDirectory()) { + if (statSync(root).isDirectory()) { throw new Error(`${root} is a directory. The Regex tag identification strategy requires a file.`) } - if (!fs.existsSync(root)) { + if (!existsSync(root)) { throw new Error(`"${root}" does not exist.`) } - this.content = fs.readFileSync(root).toString() + this.content = readFileSync(root).toString() let content = pattern.exec(this.content) if (!content) { diff --git a/src/lib/setup.js b/src/lib/setup.js index 4109c2b..13e488e 100644 --- a/src/lib/setup.js +++ b/src/lib/setup.js @@ -1,5 +1,5 @@ import core from '@actions/core' -import fs from 'fs' +import { readdirSync } from 'fs' import path from 'path' export default class Setup { @@ -11,8 +11,7 @@ export default class Setup { .join('\n -> ')}` ) - const dir = fs - .readdirSync(path.resolve(process.env.GITHUB_WORKSPACE), { withFileTypes: true }) + const dir = readdirSync(path.resolve(process.env.GITHUB_WORKSPACE), { withFileTypes: true }) .map(entry => { return `${entry.isDirectory() ? '> ' : ' - '}${entry.name}` })