@screenshotscout/cli 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -177,9 +177,10 @@ The CLI writes response data unchanged, without adding labels or summaries.
177
177
  | API response | No `--output` | `--output <path>` | `--output -` |
178
178
  | ------------------- | ----------------------------------------------- | --------------------------------------- | ----------------------------------------------- |
179
179
  | Binary image or PDF | Saves `screenshot.<extension>` | Saves exact response bytes to the path | Writes exact response bytes to standard output |
180
+ | Markdown | Writes the Markdown to standard output | Saves the Markdown to the path | Writes the Markdown to standard output |
180
181
  | JSON | Writes the raw JSON response to standard output | Saves the raw JSON response to the path | Writes the raw JSON response to standard output |
181
182
 
182
- Binary and JSON writes to standard output add no line break.
183
+ Binary, Markdown and JSON writes to standard output add no line break.
183
184
 
184
185
  For an automatically named binary response, the extension comes only from the actual response `Content-Type`: `.png`, `.jpg`, `.webp`, `.gif`, `.tiff`, or `.pdf`. A missing or unrecognized content type uses `.bin`; a requested format does not determine the automatic filename.
185
186
 
package/dist/result.js CHANGED
@@ -8,8 +8,11 @@ const DEFAULT_CAPTURE_RESULT_IO = {
8
8
  /** Save or display one successful SDK capture response without transforming it. */
9
9
  export async function writeCaptureResult(response, outputPath, io = DEFAULT_CAPTURE_RESULT_IO) {
10
10
  const bytes = response.kind === "binary" ? response.bytes : response.rawResponse.body;
11
+ // JSON and Markdown are text, so without an output path they go to standard output.
11
12
  if (outputPath === "-" ||
12
- (outputPath === undefined && response.kind === "json")) {
13
+ (outputPath === undefined &&
14
+ (response.kind === "json" ||
15
+ mediaTypeOf(response.rawResponse.contentType) === "text/markdown"))) {
13
16
  await io.writeStandardOutput(bytes);
14
17
  return;
15
18
  }
@@ -19,8 +22,7 @@ export async function writeCaptureResult(response, outputPath, io = DEFAULT_CAPT
19
22
  }
20
23
  /** Map only a returned response Content-Type to an automatic file extension. */
21
24
  export function captureFileExtension(contentType) {
22
- const mediaType = contentType?.split(";", 1)[0]?.trim().toLowerCase();
23
- switch (mediaType) {
25
+ switch (mediaTypeOf(contentType)) {
24
26
  case "image/png":
25
27
  return ".png";
26
28
  case "image/jpeg":
@@ -37,6 +39,9 @@ export function captureFileExtension(contentType) {
37
39
  return ".bin";
38
40
  }
39
41
  }
42
+ function mediaTypeOf(contentType) {
43
+ return contentType?.split(";", 1)[0]?.trim().toLowerCase();
44
+ }
40
45
  function writeStandardOutput(bytes) {
41
46
  return new Promise((resolve, reject) => {
42
47
  process.stdout.write(bytes, (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screenshotscout/cli",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Official command-line interface for the Screenshot Scout screenshot API.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,7 @@
19
19
  "format:check": "prettier --check .",
20
20
  "lint": "eslint .",
21
21
  "pretest": "npm run build",
22
- "test": "tsx --test test/**/*.test.ts",
22
+ "test": "tsx --test \"test/**/*.test.ts\"",
23
23
  "typecheck": "tsc -p tsconfig.json"
24
24
  },
25
25
  "author": "Oleksii Velykyi",