Skip to content

Commit 572232e

Browse files
committed
documentation update, json5 output opt-in.
1 parent 0ab5a63 commit 572232e

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

Extension/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ The [source](https://github.com/geeklearningio/gl-vsts-tasks-file-patch) for thi
2323

2424
## Release Notes
2525

26+
> **10-9-2016**
27+
> - Added: Patch PLIST File
28+
> - Improved: Patch JSON File with JSON5 parser support and JSON5 output support.
29+
2630
> **10-7-2016**
2731
> - Added: Patch YAML File
2832

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Visual Studio Team Services Build and Release Management extensions that help yo
2424

2525
## Release Notes
2626

27+
> **10-9-2016**
28+
> - Added: Patch PLIST File
29+
> - Improved: Patch JSON File with JSON5 parser support and JSON5 output support.
30+
2731
> **10-7-2016**
2832
> - Added: Patch YAML File
2933

Tasks/JsonPatch/json5Patcher.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@ var JSON5 = require('json5');
44

55
export class Json5Patcher extends jsonPatcher.JsonPatcher {
66

7+
constructor(
8+
patches: patch.IPatch[],
9+
private outputJson5: boolean
10+
) {
11+
super(patches);
12+
}
13+
714
parse(content: string): any {
815
return JSON5.parse(content);
916
}
1017

1118
stringify(content: any): string {
12-
return JSON5.stringify(content);
19+
if (this.outputJson5) {
20+
return JSON5.stringify(content);
21+
} else {
22+
super.stringify(content)
23+
}
1324
}
1425
}

Tasks/JsonPatch/jsonPatch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ var patterns: any = tl.getInput("JsonTargetFilters")
1515
var outputPatchedFile = tl.getBoolInput("OutputPatchFile");
1616
var syntax = tl.getInput("SyntaxType");
1717
var useJson5 = tl.getBoolInput("UseJson5");
18+
var produceJson5 = tl.getBoolInput("ProduceJson5");
1819

1920
try {
2021
var patches: patch.IPatch[] = syntax == "slick" ?
2122
patchProcess.expandVariablesAndParseSlickPatch(patchContent) :
2223
patchProcess.expandVariablesAndParseJson(patchContent);
2324

24-
var patcher = useJson5 ? new json5Patcher.Json5Patcher(patches) : new jsonPatcher.JsonPatcher(patches);
25+
var patcher = useJson5 ? new json5Patcher.Json5Patcher(patches, produceJson5) : new jsonPatcher.JsonPatcher(patches);
2526

2627
patchProcess.apply(patcher, targetPath, patterns, outputPatchedFile);
2728

Tasks/JsonPatch/task.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@
7575
"label": "Use JSON 5",
7676
"defaultValue": "false",
7777
"helpMarkDown": "This enables JSON5 syntax support"
78+
},
79+
{
80+
"name": "ProduceJson5",
81+
"type": "boolean",
82+
"label": "Produce JSON 5",
83+
"defaultValue": "false",
84+
"helpMarkDown": "This enables JSON5 output support"
7885
}
7986
],
8087
"execution": {

0 commit comments

Comments
 (0)