-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (24 loc) · 812 Bytes
/
index.js
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
'use strict';
const yaml = require('yamljs');
const path = require('path');
const packagePathResolver = require('./packagePathResolver');
const fs = require('fs-extra');
const differ = require('jest-diff');
const diffToSemver = require('./diffToSemver');
const defineVersion = (pkg, root, latestTemp) => {
let version, diff;
const updatedContent = yaml.load(
path.join(root, `${packagePathResolver(pkg)}/token.yml`)
);
const latestPath = path.join(latestTemp, 'node_modules', pkg, 'token.yml');
if (fs.pathExistsSync(latestPath)) {
const latestContent = yaml.load(latestPath);
diff = differ(latestContent.props, updatedContent.props);
version = diffToSemver(latestContent.props, updatedContent.props);
}
return {
version,
diff
};
};
module.exports = defineVersion;