mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
chore: Migrate CJS to ESM (#42059)
* chore: Migrate CJS to ESM * fix * rename
This commit is contained in:
parent
de1a73a6d6
commit
16dd7ba3cb
@ -1,13 +1,19 @@
|
|||||||
/* eslint no-console: 0 */
|
/* eslint-disable no-console */
|
||||||
const chalk = require('chalk');
|
import chalk from 'chalk';
|
||||||
const fs = require('fs');
|
import dayjs from 'dayjs';
|
||||||
const { join } = require('path');
|
import isBetween from 'dayjs/plugin/isBetween';
|
||||||
const dayjs = require('dayjs');
|
import fs from 'fs';
|
||||||
|
import { join } from 'path';
|
||||||
|
import localPackage from '../package.json';
|
||||||
|
|
||||||
const getChangelogByVersion = (content, version) => {
|
const { version } = localPackage;
|
||||||
|
|
||||||
|
dayjs.extend(isBetween);
|
||||||
|
|
||||||
|
const getChangelogByVersion = (content: string, vers: string) => {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
const changeLog = [];
|
const changeLog: string[] = [];
|
||||||
const startPattern = new RegExp(`^## ${version}`);
|
const startPattern = new RegExp(`^## ${vers}`);
|
||||||
const stopPattern = /^## /; // 前一个版本
|
const stopPattern = /^## /; // 前一个版本
|
||||||
let begin = false;
|
let begin = false;
|
||||||
for (let i = 0; i < lines.length; i += 1) {
|
for (let i = 0; i < lines.length; i += 1) {
|
||||||
@ -22,15 +28,9 @@ const getChangelogByVersion = (content, version) => {
|
|||||||
begin = startPattern.test(line);
|
begin = startPattern.test(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return changeLog.join('\n');
|
return changeLog.join('\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-dynamic-require
|
|
||||||
const packageJson = require(join(__dirname, '..', 'package.json'));
|
|
||||||
|
|
||||||
const { version } = packageJson;
|
|
||||||
|
|
||||||
if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
||||||
console.log('\n');
|
console.log('\n');
|
||||||
console.log(chalk.blue('[check-version-md]: Prerelease Version. Skipped.'));
|
console.log(chalk.blue('[check-version-md]: Prerelease Version. Skipped.'));
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
echo "[TEST ALL] test changelog"
|
echo "[TEST ALL] test changelog"
|
||||||
echo "[TEST ALL] test changelog" > ~test-all.txt
|
echo "[TEST ALL] test changelog" > ~test-all.txt
|
||||||
# node ./scripts/check-version-md.js
|
# node ./scripts/check-version-md.ts
|
||||||
|
|
||||||
echo "[TEST ALL] check-commit"
|
echo "[TEST ALL] check-commit"
|
||||||
echo "[TEST ALL] check-commit" > ~test-all.txt
|
echo "[TEST ALL] check-commit" > ~test-all.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user