Skip to content

Commit

Permalink
Merge pull request #2 from sun-yryr/update-actions-core
Browse files Browse the repository at this point in the history
Update actions core & remove json comment
  • Loading branch information
sun-yryr authored Jul 15, 2020
2 parents fb0473e + 41d8fa2 commit 72336e2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
"@types/node": "^13.7.7",
"@types/yarnpkg__lockfile": "^1.1.3",
"hard-source-webpack-plugin": "^0.13.1",
"strip-json-comments": "^3.1.1",
"ts-loader": "^6.2.2",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"@actions/core": "^1.2.3",
"@actions/core": "^1.2.4",
"@yarnpkg/lockfile": "^1.1.0",
"concat-stream": "^2.0.0",
"glob": "^7.1.6"
Expand Down
48 changes: 27 additions & 21 deletions src/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createHost, createService } from './langSvc'
import { Reporter } from './reporter'
import { FileEntry } from './types'
import { getAllLibs, uniq } from './utils'
import stripJsonComments from 'strip-json-comments'

export class Doctor {
private service: _ts.LanguageService
Expand All @@ -19,30 +20,35 @@ export class Doctor {
}

static fromConfigFile(configPath: string, ts: typeof _ts): Doctor {
const content = fs.readFileSync(configPath).toString();
const parsed = ts.parseJsonConfigFileContent(
const content = stripJsonComments(fs.readFileSync(configPath).toString(), {whitespace: false});
try {
const parsed = ts.parseJsonConfigFileContent(
JSON.parse(content),
ts.sys,
path.dirname(configPath)
);
const compilerOptions = parsed.options

const defaultLibFileName = _ts.getDefaultLibFileName(compilerOptions)
const libs = [defaultLibFileName, ...(compilerOptions.lib || [])]
const allLibs = getAllLibs(uniq(libs))

/**
* Note:
*
* since we use CDN-hosted TS runtime, which is a bundled version,
* we need to manually added lib.*.d.ts.
*/
const fileNames = [
...parsed.fileNames,
...allLibs
]

return new Doctor(fileNames, compilerOptions, ts)
);
const compilerOptions = parsed.options

const defaultLibFileName = _ts.getDefaultLibFileName(compilerOptions)
const libs = [defaultLibFileName, ...(compilerOptions.lib || [])]
const allLibs = getAllLibs(uniq(libs))

/**
* Note:
*
* since we use CDN-hosted TS runtime, which is a bundled version,
* we need to manually added lib.*.d.ts.
*/
const fileNames = [
...parsed.fileNames,
...allLibs
]

return new Doctor(fileNames, compilerOptions, ts)
} catch (error) {
console.error(error)
throw error
}
}

getSemanticDiagnostics() {
Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@actions/core@^1.2.3":
version "1.2.3"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95"
integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==
"@actions/core@^1.2.4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab"
integrity sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg==

"@types/concat-stream@^1.6.0":
version "1.6.0"
Expand Down Expand Up @@ -2509,6 +2509,11 @@ strip-eof@^1.0.0:
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=

strip-json-comments@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==

[email protected]:
version "6.1.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3"
Expand Down

0 comments on commit 72336e2

Please sign in to comment.