Skip to content

Commit 2ec0100

Browse files
committed
feat: 优化调试日志和执行命令的输出
- 在主函数中添加调试日志,输出所有选项 - 修改执行命令的输出格式,增加提示符号 - 为 publishPackages 函数添加进度指示,显示当前处理的包序号
1 parent 9caf423 commit 2ec0100

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ async function main() {
3232
options[key as keyof PublishOptions] = input === undefined ? defaultVal : input;
3333
}
3434

35+
if (core.isDebug()) {
36+
core.debug(`Options: ${JSON.stringify(options, null, 2)}`);
37+
}
38+
3539
// 2. 重写 package.json + 发布
3640
await publishPackages(options);
3741
}

src/publish-package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const registries: Record<PublishTarget, string> = {
1212
export function publishPackage(pkgPath: string, options: InternalPublishOptions) {
1313
const cwd = path.resolve(pkgPath, '..');
1414
const exec = (command: string) => {
15-
core.info(command);
15+
core.info(`> ${command}`);
1616
cp.execSync(command, {
1717
cwd,
1818
stdio: 'inherit',

src/publish-packages.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ export async function publishPackages(options: InternalPublishOptions) {
4242

4343
const pkgPaths = ['package.json', ...childPkgPaths];
4444
core.info(`pkgPaths: ${JSON.stringify(pkgPaths)}`);
45+
const length = pkgPaths.length;
4546

47+
let order = 1;
4648
for (const pkgPath of pkgPaths) {
47-
core.info(`read package ${pkgPath}`);
49+
core.info(`[${order++}/${length}] read package ${pkgPath}`);
4850

4951
const pkgFile = path.join(cwd, pkgPath);
5052
const origin = fs.readFileSync(pkgFile, 'utf-8');

0 commit comments

Comments
 (0)