UNPKG

1.03 kBJavaScriptView Raw
1/*
2|--------------------------------------------------------------------------
3| npm publush 前检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
4|--------------------------------------------------------------------------
5*/
6
7const chalk = require('chalk');
8const pkg = require('../package.json');
9const fs = require('fs');
10const path = require('path');
11const helDistPath = path.resolve(__dirname, '../hel_dist/hel-meta.json');
12const existHelMeata = fs.existsSync(helDistPath);
13
14// 检查是否执行npm run build 打包命令
15if (!existHelMeata) {
16 console.log(chalk.red("Run the 'npm run build' command first.\n"));
17 process.exit(1);
18}
19const { app } = JSON.parse(fs.readFileSync(helDistPath, 'utf-8'));
20// 检查根目录下 package.json 的版本号是否和 hel_dist/hel-meta.json 一致
21if (app?.build_version !== pkg.version) {
22 console.log(
23 chalk.red('The package.json version number and the hel_dist/hel-meta.json version number must be the same.\n')
24 );
25 process.exit(1);
26}