Spaces:
Running
Running
| /** | |
| * Copyright (c) 2017~2021, OBCon Inc. | |
| * All rights reserved. | |
| */ | |
| /** | |
| * @file | |
| * @copyright 2017~2021, OBCon Inc. | |
| * @author gye hyun james kim [pnuskgh@gmail.com] | |
| */ | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| class Version { | |
| constructor() { | |
| this._filename = path.join(appl.root, 'version.json'); | |
| this._version = null; | |
| } | |
| get version() { | |
| if (this._version == null) { | |
| this._version = this.read() | |
| } | |
| return this._version; | |
| } | |
| set version(newValue) { | |
| this._version = newValue; | |
| } | |
| read(filename=this._filename) { | |
| return require(filename); | |
| } | |
| write(version=this._version, filename=this._filename) { | |
| fs.writeFileSync(filename, JSON.stringify(version), 'utf8'); | |
| } | |
| next() { | |
| let version = this.version; | |
| version.patch = version.patch + 1; | |
| version.minor = version.minor + parseInt(version.patch / 100); | |
| version.major = version.major + parseInt(version.minor / 10); | |
| version.minor = version.minor % 10; | |
| version.patch = version.patch % 100; | |
| // let international = Intl.NumberFormat('ko-KR', { minimumFractionDigits: 0, maximumFractionDigits: 0 }); | |
| // let internationalFloat = Intl.NumberFormat('ko-KR', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); | |
| version.version = `${version.major}.${String(version.minor).padStart(2, '0')}.${String(version.patch).padStart(3, '0')}`; | |
| // console.log(version); | |
| this._version = version | |
| return version; | |
| } | |
| } | |
| module.exports = Version; | |