Skip to content

Commit cf9a873

Browse files
author
Danny McCormick
authored
Dont fail on missing package.json (#349)
* Dont fail on missing package.json * Feedback
1 parent f21b5bf commit cf9a873

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

api/WebApi.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ export class WebApi {
145145
userAgent = `${nodeApiName} (${window.navigator.userAgent})`;
146146
}
147147
} else {
148-
const nodeApiVersion: string = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')).version;
148+
let nodeApiVersion: string = 'unknown';
149+
const packageJsonPath: string = path.resolve(__dirname, 'package.json');
150+
if (fs.existsSync(packageJsonPath)) {
151+
nodeApiVersion = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')).version;
152+
}
149153
const osName: string = os.platform();
150154
const osVersion: string = os.release();
151155

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azure-devops-node-api",
33
"description": "Node client for Azure DevOps and TFS REST APIs",
4-
"version": "9.0.2",
4+
"version": "9.0.3",
55
"main": "./WebApi.js",
66
"types": "./WebApi.d.ts",
77
"scripts": {

0 commit comments

Comments
 (0)