mirror of
https://github.com/ButlerLogic/action-autotag.git
synced 2024-11-10 18:31:08 +07:00
24 lines
493 B
JavaScript
24 lines
493 B
JavaScript
|
import fs from 'fs'
|
||
|
import path from 'path'
|
||
|
|
||
|
export default class Package {
|
||
|
constructor (root = './') {
|
||
|
root = path.join(process.env.GITHUB_WORKSPACE, root)
|
||
|
|
||
|
if (fs.statSync(root).isDirectory()) {
|
||
|
root = path.join(root, 'package.json')
|
||
|
}
|
||
|
|
||
|
if (!fs.existsSync(root)) {
|
||
|
throw new Error(`package.json does not exist at ${root}.`)
|
||
|
}
|
||
|
|
||
|
this.root = root
|
||
|
this.data = JSON.parse(fs.readFileSync(root))
|
||
|
}
|
||
|
|
||
|
get version () {
|
||
|
return this.data.version
|
||
|
}
|
||
|
}
|