Skip to content

Commit

Permalink
fix: read context file sync way when calling context model (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg authored Sep 4, 2023
1 parent 10707a7 commit 62facb0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ asyncapi.json
asyncapi.yml
test/minimaltemplate/__transpiled
.vscode


oclif.manifest.json
spec-examples.zip
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
},
"repository": "asyncapi/cli",
"scripts": {
"build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && echo \"Build Completed\"",
"build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && oclif manifest && echo \"Build Completed\"",
"bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION",
"dev": "tsc --watch",
"docker:build": "docker build -t asyncapi/cli:latest .",
Expand All @@ -143,8 +143,7 @@
"pack:tarballs": "oclif pack tarballs -t linux-x64 && npm run pack:rename",
"pack:windows": "oclif pack win && npm run pack:rename",
"pack:rename": "node scripts/releasePackagesRename.js",
"postpack": "rimraf oclif.manifest.json",
"prepublishOnly": "npm run build && oclif manifest",
"prepublishOnly": "npm run build",
"pretest:coverage": "npm run build",
"release": "semantic-release",
"pretest": "npm run build",
Expand Down
7 changes: 3 additions & 4 deletions src/models/Context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { promises as fs, existsSync, lstatSync } from 'fs';
import { readFileSync, promises as fs, existsSync, lstatSync } from 'fs';
import * as path from 'path';
import * as os from 'os';

Expand Down Expand Up @@ -329,9 +329,8 @@ async function getContextFilePath(): Promise<string | null> {
// legitimate context file, then it is considered a legitimate context
// file indeed.
const fileContent = JSON.parse(
await readFile(currentPathString, {
encoding: 'utf8',
})
//we do not use await readFile because getContextFilePath cannot be called inside async function
readFileSync(currentPathString, {encoding: 'utf8'})
);
if (
fileContent &&
Expand Down

0 comments on commit 62facb0

Please sign in to comment.