Initial work of ESM transformation
This commit is contained in:
parent
2472c9cff2
commit
b8205a63aa
303 changed files with 1959 additions and 2450 deletions
|
@ -1,40 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const semver = require("semver");
|
||||
|
||||
const ChangeFileDir = path.join(__dirname, "../../changes");
|
||||
const PackageJsonPath = path.join(__dirname, "../../package.json");
|
||||
|
||||
setTimeout(
|
||||
() =>
|
||||
main().catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}),
|
||||
0
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
async function main() {
|
||||
const version = await GetLatestVersion();
|
||||
const packageJson = JSON.parse(await fs.promises.readFile(PackageJsonPath));
|
||||
packageJson.version = version;
|
||||
await fs.promises.writeFile(PackageJsonPath, JSON.stringify(packageJson, null, " ") + "\n");
|
||||
}
|
||||
|
||||
async function GetLatestVersion() {
|
||||
const changeFiles = await fs.promises.readdir(ChangeFileDir);
|
||||
const versions = new Set();
|
||||
for (const file of changeFiles) {
|
||||
const filePath = path.join(ChangeFileDir, file);
|
||||
const fileParts = path.parse(filePath);
|
||||
if (fileParts.ext !== ".md") continue;
|
||||
if (!semver.valid(fileParts.name)) continue;
|
||||
versions.add(fileParts.name);
|
||||
}
|
||||
const sortedVersions = Array.from(versions).sort((a, b) => semver.compare(b, a));
|
||||
return sortedVersions[0];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue