FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TypeScript/scripts/checkModuleFormat.mjs at main · fdln/TypeScript · GitHub
fdln
/
TypeScript
Public
forked from
microsoft/TypeScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TypeScript
/
scripts
/
checkModuleFormat.mjs
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (36 loc) · 1.36 KB
Breadcrumbs
TypeScript
/
scripts
/
checkModuleFormat.mjs
Copy path
File metadata and controls
41 lines (36 loc) · 1.36 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
import
{
createRequire
}
from
"module"
;
import
{
__importDefault
,
__importStar
}
from
"tslib"
;
// This script tests that TypeScript's CJS API is structured
// as expected. It calls "require" as though it were in CWD,
// so it can be tested on a separate install of TypeScript.
const
require
=
createRequire
(
process
.
cwd
(
)
+
"/index.js"
)
;
console
.
log
(
`Testing
${
process
.
argv
[
2
]
}
...`
)
;
const
ts
=
require
(
process
.
argv
[
2
]
)
;
// See: https://github.com/microsoft/TypeScript/pull/51474#issuecomment-1310871623
/**
@type
{
[fn: (() => any), shouldSucceed: boolean][]
} */
const
fns
=
[
[
(
)
=>
ts
.
version
,
true
]
,
[
(
)
=>
ts
.
default
.
version
,
false
]
,
[
(
)
=>
__importDefault
(
ts
)
.
version
,
false
]
,
[
(
)
=>
__importDefault
(
ts
)
.
default
.
version
,
true
]
,
[
(
)
=>
__importStar
(
ts
)
.
version
,
true
]
,
[
(
)
=>
__importStar
(
ts
)
.
default
.
version
,
true
]
,
]
;
for
(
const
[
fn
,
shouldSucceed
]
of
fns
)
{
let
success
=
false
;
try
{
success
=
!
!
fn
(
)
;
}
catch
{
// Ignore
}
const
status
=
success
?
"succeeded"
:
"failed"
;
if
(
success
===
shouldSucceed
)
{
console
.
log
(
`
${
fn
.
toString
(
)
}
${
status
}
as expected.`
)
;
}
else
{
console
.
log
(
`
${
fn
.
toString
(
)
}
unexpectedly
${
status
}
.`
)
;
process
.
exitCode
=
1
;
}
}
console
.
log
(
"ok"
)
;
Back
|
FazBrowse Home
|
New Git URL