FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TypeScript/scripts/run-failed-tests.js at arrayReduce · UmeshP53/TypeScript · GitHub
UmeshP53
/
TypeScript
Public
forked from
microsoft/TypeScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
TypeScript
/
scripts
/
run-failed-tests.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
92 lines (83 loc) · 2.26 KB
Breadcrumbs
TypeScript
/
scripts
/
run-failed-tests.js
Copy path
File metadata and controls
92 lines (83 loc) · 2.26 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const
spawn
=
require
(
'child_process'
)
.
spawn
;
const
os
=
require
(
"os"
)
;
const
fs
=
require
(
"fs"
)
;
const
path
=
require
(
"path"
)
;
let
grep
;
try
{
const
failedTests
=
fs
.
readFileSync
(
".failed-tests"
,
"utf8"
)
;
grep
=
failedTests
.
split
(
/
\r
?
\n
/
g
)
.
map
(
test
=>
test
.
trim
(
)
)
.
filter
(
test
=>
test
.
length
>
0
)
.
map
(
escapeRegExp
)
;
}
catch
(
e
)
{
grep
=
[
]
;
}
let
args
=
[
]
;
let
waitForGrepValue
=
false
;
let
grepIndex
=
-
1
;
process
.
argv
.
slice
(
2
)
.
forEach
(
(
arg
,
index
)
=>
{
const
[
flag
,
value
]
=
arg
.
split
(
'='
)
;
if
(
flag
===
"g"
||
flag
===
"grep"
)
{
grepIndex
=
index
-
1
;
waitForGrepValue
=
arg
!==
flag
;
if
(
!
waitForGrepValue
)
grep
.
push
(
value
.
replace
(
/
^
"
|
"
$
/
g
,
""
)
)
;
return
;
}
if
(
waitForGrepValue
)
{
grep
.
push
(
arg
.
replace
(
/
^
"
|
"
$
/
g
,
""
)
)
;
waitForGrepValue
=
false
;
return
;
}
args
.
push
(
arg
)
;
}
)
;
let
mocha
=
"./node_modules/mocha/bin/mocha"
;
let
grepOption
;
let
grepOptionValue
;
let
grepFile
;
if
(
grep
.
length
)
{
grepOption
=
"--grep"
;
grepOptionValue
=
grep
.
join
(
"|"
)
;
if
(
grepOptionValue
.
length
>
20
)
{
grepFile
=
path
.
resolve
(
os
.
tmpdir
(
)
,
".failed-tests.opts"
)
;
fs
.
writeFileSync
(
grepFile
,
`--grep
${
grepOptionValue
}
`
,
"utf8"
)
;
grepOption
=
"--opts"
;
grepOptionValue
=
grepFile
;
mocha
=
"./node_modules/mocha/bin/_mocha"
;
}
}
if
(
grepOption
)
{
if
(
grepIndex
>=
0
)
{
args
.
splice
(
grepIndex
,
0
,
grepOption
,
grepOptionValue
)
;
}
else
{
args
.
push
(
grepOption
,
grepOptionValue
)
;
}
}
args
.
unshift
(
path
.
resolve
(
mocha
)
)
;
console
.
log
(
args
.
join
(
" "
)
)
;
const
proc
=
spawn
(
process
.
execPath
,
args
,
{
stdio
:
'inherit'
}
)
;
proc
.
on
(
'exit'
,
(
code
,
signal
)
=>
{
process
.
on
(
'exit'
,
(
)
=>
{
if
(
grepFile
)
{
fs
.
unlinkSync
(
grepFile
)
;
}
if
(
signal
)
{
process
.
kill
(
process
.
pid
,
signal
)
;
}
else
{
process
.
exit
(
code
)
;
}
}
)
;
}
)
;
process
.
on
(
'SIGINT'
,
(
)
=>
{
proc
.
kill
(
'SIGINT'
)
;
proc
.
kill
(
'SIGTERM'
)
;
}
)
;
function
escapeRegExp
(
pattern
)
{
return
pattern
.
replace
(
/
[
^
-
\w
\d
\s
]
/
g
,
match
=>
"\\"
+
match
)
.
replace
(
/
\s
/
g
,
"\\s"
)
;
}
Back
|
FazBrowse Home
|
New Git URL