diff --git a/commands/publish/README.md b/commands/publish/README.md
index 82a6c08323f..7f56faf4b6d 100644
--- a/commands/publish/README.md
+++ b/commands/publish/README.md
@@ -65,6 +65,7 @@ This is useful when a previous `lerna publish` failed to publish all packages to
- [`--tag-version-prefix`](#--tag-version-prefix)
- [`--temp-tag`](#--temp-tag)
- [`--yes`](#--yes)
+- [`--summary-file
`](#--summary-file)
### `--canary`
@@ -291,6 +292,27 @@ lerna publish --canary --yes
When run with this flag, `lerna publish` will skip all confirmation prompts.
Useful in [Continuous integration (CI)](https://en.wikipedia.org/wiki/Continuous_integration) to automatically answer the publish confirmation prompt.
+### `--summary-file`
+
+```sh
+lerna publish --canary --yes --summary-file ./output.json
+```
+
+When run with this flag, once a successfully publish it will create a json summary report(see below for an example).
+
+```json
+[
+ {
+ "packageName": "package1",
+ "version": "v1.0.1-alpha"
+ },
+ {
+ "packageName": "package2",
+ "version": "v2.0.1-alpha"
+ }
+]
+```
+
## Deprecated Options
### `--skip-npm`
diff --git a/commands/publish/index.js b/commands/publish/index.js
index 3bea84e3cfa..a68a37239d9 100644
--- a/commands/publish/index.js
+++ b/commands/publish/index.js
@@ -252,8 +252,12 @@ class PublishCommand extends Command {
};
});
output(jsonObject);
- // TODO: Add error handling so it won't crash if it fails.
- fs.writeFileSync(filePath, JSON.stringify(jsonObject));
+ try {
+ fs.writeFileSync(filePath, JSON.stringify(jsonObject));
+ output("Locate Summary Report Here: ", filePath);
+ } catch (error) {
+ output("Failed to create the summary report", error);
+ }
} else {
const message = this.packagesToPublish.map(pkg => ` - ${pkg.name}@${pkg.version}`);
output(message.join(os.EOL));