-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathversions.js
More file actions
32 lines (27 loc) · 924 Bytes
/
versions.js
File metadata and controls
32 lines (27 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('node:fs');
const path = require('node:path');
class Versions {
constructor() {
this.versions = {};
}
async get(type) {
const version = this.versions[type];
if (version) {
return version;
} else if (typeof this[type] === 'function') {
this.versions[type] = await this[type]();
return this.versions[type];
}
}
async beaver() {
const json = await fs.promises.readFile(path.resolve(__dirname, 'package.json'));
const data = JSON.parse(json);
return typeof data === 'object' && data.version;
}
async yaumnrc() {
const json = await fs.promises.readFile(path.resolve(path.dirname(require.resolve('clean-yaumnrc')), 'package.json'));
const data = JSON.parse(json);
return typeof data === 'object' && data.version;
}
}
module.exports = new Versions();