为什么 Lerna 在根项目中创建了很多 .tgz 文件?

Why Lerna creates a lot of .tgz files at root project ?

我正在使用 Lerna,当我使用 lerna publish 时,在我的项目的根目录下创建了很多 .tgz 文件。如何保存要创建的这些文件?感谢您的任何提示。

这里是我的项目根目录:

28/09/2018 16:25 99 847 hoco_editor-alignment_plugin-1.1.0.tgz 28/09/2018 16:58 100 183 hoco_editor-alignment_plugin-1.2.0.tgz 28/09/2018 16:25
102 772 hoco_editor-bold_plugin-1.1.0.tgz 28/09/2018 16:58
102 875 hoco_editor-bold_plugin-1.2.0.tgz 28/09/2018 16:25
1 299 hoco_editor-embed_plugin-1.1.0.tgz 28/09/2018 16:58
1 507 hoco_editor-embed_plugin-1.2.0.tgz 28/09/2018 16:25
4 072 hoco_editor-font_family_plugin-1.1.0.tgz 28/09/2018 16:58
4 257 hoco_editor-font_family_plugin-1.2.0.tgz 28/09/2018 16:25
4 281 hoco_editor-font_size_plugin-1.1.0.tgz 28/09/2018 16:58
4 465 hoco_editor-font_size_plugin-1.2.0.tgz 28/09/2018 16:25
2 128 hoco_editor-image_plugin-1.1.0.tgz 28/09/2018 16:58
2 317 hoco_editor-image_plugin-1.2.0.tgz 28/09/2018 16:25
2 221 hoco_editor-italic_plugin-1.1.0.tgz 28/09/2018 16:58
2 412 hoco_editor-italic_plugin-1.2.0.tgz 28/09/2018 16:25
1 332 hoco_editor-link_plugin-1.1.0.tgz 28/09/2018 16:58
1 537 hoco_editor-link_plugin-1.2.0.tgz 28/09/2018 16:25
653 hoco_editor-list_plugin-1.1.0.tgz 28/09/2018 16:58
866 hoco_editor-list_plugin-1.2.0.tgz 28/09/2018 16:25
657 hoco_editor-toggle_readonly-1.1.0.tgz 28/09/2018 16:58
873 hoco_editor-toggle_readonly-1.2.0.tgz 28/09/2018 16:25
5 146 hoco_editor-ui-1.1.0.tgz 28/09/2018 16:58 5 332 hoco_editor-ui-1.2.0.tgz

我相信当 npm publish 失败并且 lerna 没有清理 npm pack 生成的 tarball 时会发生这种情况。 如果您深入了解 lerna 的源代码,请查看:

https://github.com/lerna/lerna/blob/5da13190852897ac37349a28a0b24470ec7bd833/utils/npm-publish/npm-publish.js#L40

基本上是这样的:

return ChildProcessUtilities.exec(npmClient, args, opts).then(() =>
    // don't leave the generated tarball hanging around after success
    fs.remove(path.join(pkg.location, pkg.tarball.filename)).then(() => pkg)
  );

因此,如果 npm(或 yarn)发布失败,则 tarball 不会被删除。

您可以安全地删除这些文件,因为它们只是发布过程的临时产物,一开始就不应该存在。