Skip to content

Commit 1fc574a

Browse files
Copilotcongminh1254
andcommitted
Update yaml.safeDump to yaml.dump for js-yaml 4.x compatibility
Co-authored-by: congminh1254 <9329079+congminh1254@users.noreply.github.com>
1 parent c9db8b6 commit 1fc574a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/box-command.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,18 @@ function formatObject(obj) {
256256
let outputData = formatObjectKeys(obj);
257257

258258
// Other objects are formatted as YAML for human-readable output
259-
let yamlString = yaml.safeDump(outputData, {
259+
let yamlString = yaml.dump(outputData, {
260260
indent: 4,
261261
noRefs: true,
262262
});
263263

264+
// js-yaml 4.x changed its quoting behavior for certain strings.
265+
// For backward compatibility with js-yaml 3.x output:
266+
// 1. Quote URLs (http:// or https://)
267+
yamlString = yamlString.replaceAll(/^(\s*)([^:]+): (https?:\/\/[^\s]+)$/gmu, "$1$2: '$3'");
268+
// 2. Unquote numeric strings starting with 0 (js-yaml 3.x didn't quote these)
269+
yamlString = yamlString.replaceAll(/^(\s*)([^:]+): '(0\d+)'$/gmu, '$1$2: $3');
270+
264271
// The YAML library puts a trailing newline at the end of the string, which is
265272
// redundant with the automatic newline added by oclif when writing to stdout
266273
return yamlString

0 commit comments

Comments
 (0)