Skip to content

Commit

Permalink
fix(vscode): More lenient JSON parsing (allow for trailing commas) (#902
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mrmeku authored and jaysoo committed Nov 21, 2019
1 parent 1107d59 commit ecbd0ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 59 deletions.
5 changes: 2 additions & 3 deletions libs/server/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { execSync } from 'child_process';
import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
import { platform } from 'os';
import * as path from 'path';

import * as stripJsonComments from 'strip-json-comments';
import * as JSON5 from 'json5';

export interface SchematicDefaults {
[name: string]: string;
Expand Down Expand Up @@ -144,7 +143,7 @@ export function fileExistsSync(filePath: string): boolean {
}

export function readAndParseJson(fullFilePath: string): any {
return JSON.parse(stripJsonComments(readFileSync(fullFilePath).toString()));
return JSON5.parse(readFileSync(fullFilePath).toString());
}

export function readAndCacheJsonFile(
Expand Down
22 changes: 8 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
"@angular-devkit/build-angular": "^0.803.3",
"@angular/cli": "8.3.18",
"@angular/common": "8.2.13",
"@angular/compiler": "8.2.13",
"@angular/compiler-cli": "8.2.13",
"@angular/compiler": "8.2.13",
"@angular/core": "8.2.13",
"@angular/forms": "8.2.13",
"@angular/platform-browser": "8.2.13",
"@angular/platform-browser-dynamic": "8.2.13",
"@angular/platform-browser": "8.2.13",
"@nrwl/angular": "8.7.0",
"@nrwl/cypress": "8.7.0",
"@nrwl/jest": "8.7.0",
Expand All @@ -43,39 +43,33 @@
"@types/jest": "24.0.9",
"@types/node": "12.12.7",
"@types/shelljs": "^0.8.2",
"@types/strip-json-comments": "^0.0.30",
"@types/tmp": "^0.0.33",
"@types/universal-analytics": "0.4.2",
"@types/uuid": "^3.4.5",
"codelyzer": "5.1.0",
"cypress": "3.4.0",
"fast-glob": "3.0.4",
"husky": "^3.0.9",
"jest": "24.1.0",
"jest-preset-angular": "7.0.0",
"nps": "5.9.3",
"jest": "24.1.0",
"json5": "^2.1.1",
"nps-utils": "1.7.0",
"nps": "5.9.3",
"prettier": "1.16.4",
"pretty-quick": "^1.11.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.3",
"shelljs": "0.8.3",
"shx": "^0.3.2",
"source-map-explorer": "^1.8.0",
"strip-json-comments": "2.0.1",
"stylelint": "^10.1.0",
"stylelint-config-standard": "^18.3.0",
"tmp": "^0.1.0",
"stylelint": "^10.1.0",
"ts-jest": "24.0.2",
"ts-node": "8.0.2",
"tsickle": "0.35.0",
"tslib": "1.9.3",
"tslint": "5.12.1",
"tslint-no-unused-expression-chai": "^0.1.4",
"tslint": "5.12.1",
"typescript": "3.5.3",
"universal-analytics": "0.4.20",
"uuid": "3.3.2",
"vsce": "^1.66.0",
"vsce": "^1.69.0",
"vscode": "^1.1.35",
"zlib": "^1.0.5",
"zone.js": "0.9.1"
Expand Down
48 changes: 6 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1588,16 +1588,6 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==

"@types/strip-json-comments@^0.0.30":
version "0.0.30"
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
integrity sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==

"@types/tmp@^0.0.33":
version "0.0.33"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.0.33.tgz#1073c4bc824754ae3d10cfab88ab0237ba964e4d"
integrity sha1-EHPEvIJHVK49EM+riKsCN7qWTk0=

"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
Expand Down Expand Up @@ -2021,11 +2011,6 @@ are-we-there-yet@~1.1.2:
delegates "^1.0.0"
readable-stream "^2.0.6"

arg@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.1.tgz#485f8e7c390ce4c5f78257dbea80d4be11feda4c"
integrity sha512-SlmP3fEA88MBv0PypnXZ8ZfJhwmDeIE3SP71j37AiXQBXYosPV0x6uISAaHYSlSVhmHOVkomen0tbGk6Anlebw==

argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
Expand Down Expand Up @@ -3859,7 +3844,7 @@ diff-sequences@^24.9.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==

[email protected], diff@^3.1.0, diff@^3.2.0:
[email protected], diff@^3.2.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
Expand Down Expand Up @@ -6731,7 +6716,7 @@ json3@^3.3.2:
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81"
integrity sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA==

[email protected], json5@^2.1.0:
[email protected], json5@^2.1.0, json5@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6"
integrity sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==
Expand Down Expand Up @@ -7154,7 +7139,7 @@ make-dir@^3.0.0:
dependencies:
semver "^6.0.0"

[email protected], make-error@^1.1.1:
[email protected]:
version "1.3.5"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==
Expand Down Expand Up @@ -9278,7 +9263,7 @@ redent@^2.0.0:
indent-string "^3.0.0"
strip-indent "^2.0.0"

reflect-metadata@0.1.13, reflect-metadata@^0.1.2:
reflect-metadata@^0.1.2:
version "0.1.13"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==
Expand Down Expand Up @@ -10850,7 +10835,7 @@ [email protected], tmp@^0.0.33:
dependencies:
os-tmpdir "~1.0.2"

[email protected], tmp@^0.1.0:
[email protected]:
version "0.1.0"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877"
integrity sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==
Expand Down Expand Up @@ -11025,17 +11010,6 @@ [email protected]:
micromatch "^3.1.4"
semver "^5.0.1"

[email protected]:
version "8.0.2"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.0.2.tgz#9ecdf8d782a0ca4c80d1d641cbb236af4ac1b756"
integrity sha512-MosTrinKmaAcWgO8tqMjMJB22h+sp3Rd1i4fdoWY4mhBDekOwIAKI/bzmRi7IcbCmjquccYg2gcF6NBkLgr0Tw==
dependencies:
arg "^4.1.0"
diff "^3.1.0"
make-error "^1.1.1"
source-map-support "^0.5.6"
yn "^3.0.0"

[email protected]:
version "3.2.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-3.2.0.tgz#6e70bd42915ad0efb64d3385163f0c1270f3e04d"
Expand Down Expand Up @@ -11429,11 +11403,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=

[email protected]:
version "3.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==

uuid@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a"
Expand Down Expand Up @@ -11508,7 +11477,7 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==

vsce@^1.66.0:
vsce@^1.69.0:
version "1.69.0"
resolved "https://registry.yarnpkg.com/vsce/-/vsce-1.69.0.tgz#3d862a42103192c1c79724d9fcb384a61e859d25"
integrity sha512-mRSlfrTb6rw8UVFZpJ3w++s0wd4S/OPjhUgSmspjiuy96HQEqOdpPF6S/ssYs0SqE/hMh6grmAYE0MLUmi1w4Q==
Expand Down Expand Up @@ -12177,11 +12146,6 @@ yazl@^2.2.2:
dependencies:
buffer-crc32 "~0.2.3"

yn@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==

zlib@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/zlib/-/zlib-1.0.5.tgz#6e7c972fc371c645a6afb03ab14769def114fcc0"
Expand Down

0 comments on commit ecbd0ee

Please sign in to comment.