FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ios/scripts/get-npm-tag.js at main · NativeScript/ios · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
NativeScript
/
ios
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
42
Star
150
Code
Issues
52
Pull requests
20
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ios
/
scripts
/
get-npm-tag.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (37 loc) · 1.09 KB
Breadcrumbs
ios
/
scripts
/
get-npm-tag.js
Copy path
File metadata and controls
44 lines (37 loc) · 1.09 KB
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const
semver
=
require
(
"semver"
)
;
const
{
parseArgs
}
=
require
(
"node:util"
)
;
const
USAGE
=
`Usage: node scripts/get-npm-tag.js [--version <version>]
--version version to derive the npm dist-tag from
(default: $NPM_VERSION, then package.json)
-h, --help show this help`
;
let
values
;
try
{
(
{
values
}
=
parseArgs
(
{
options
:
{
version
:
{
type
:
"string"
}
,
help
:
{
type
:
"boolean"
,
short
:
"h"
,
default
:
false
}
,
}
,
}
)
)
;
}
catch
(
e
)
{
console
.
error
(
e
.
message
)
;
console
.
error
(
USAGE
)
;
process
.
exit
(
1
)
;
}
if
(
values
.
help
)
{
console
.
log
(
USAGE
)
;
process
.
exit
(
0
)
;
}
const
currentVersion
=
values
.
version
||
process
.
env
.
NPM_VERSION
||
require
(
"../package.json"
)
.
version
;
function
validateNpmTag
(
version
)
{
const
parsed
=
semver
.
parse
(
version
)
;
return
(
parsed
.
prerelease
.
length
===
0
||
/
^
[
a
-
z
A
-
Z
]
+
$
/
.
test
(
parsed
.
prerelease
[
0
]
)
)
;
}
function
getNpmTag
(
version
)
{
if
(
!
validateNpmTag
(
version
)
)
throw
new
Error
(
"Invalid npm tag"
)
;
const
parsed
=
semver
.
parse
(
version
)
;
return
parsed
.
prerelease
[
0
]
||
"latest"
;
}
console
.
log
(
getNpmTag
(
currentVersion
)
)
;
Back
|
FazBrowse Home
|
New Git URL