FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hlambda-core/src/utils/readPackageVersion.js at master · hlambda/hlambda-core · GitHub
hlambda
hlambda-core
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
hlambda-core
/
src
/
utils
/
readPackageVersion.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (20 loc) · 762 Bytes
Breadcrumbs
hlambda-core
/
src
/
utils
/
readPackageVersion.js
Copy path
File metadata and controls
24 lines (20 loc) · 762 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import
{
readFile
}
from
'fs/promises'
;
import
readPackageJson
from
'./readPackageJson.js'
;
const
readPackageVersion
=
async
(
)
=>
{
/*
Few ways to approach this, but it seems that the most logical one is to relay on the npm
We could read package.json and parse it but we already have this info in the env variable.
This function is to futureproof the loading of the server version.
*/
if
(
typeof
process
.
env
.
npm_package_version
===
'string'
)
{
const
getPackageVersion
=
process
.
env
.
npm_package_version
??
'-'
;
return
getPackageVersion
;
}
const
data
=
await
readPackageJson
(
)
.
then
(
(
jsonData
)
=>
{
return
jsonData
;
}
)
.
catch
(
(
error
)
=>
{
}
)
;
return
data
?.
version
??
'-'
;
}
;
export
default
readPackageVersion
;
Back
|
FazBrowse Home
|
New Git URL