FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-harmonize/index.js at master · dcodeIO/node-harmonize · GitHub
This repository was archived by the owner on Jun 5, 2020. It is now read-only.
dcodeIO
/
node-harmonize
Public archive
Notifications
You must be signed in to change notification settings
Fork
6
Star
25
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-harmonize
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (49 loc) · 1.78 KB
Breadcrumbs
node-harmonize
/
index.js
Copy path
File metadata and controls
58 lines (49 loc) · 1.78 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
"use strict"
;
module
.
exports
=
harmonize
;
var
child_process
=
require
(
"child_process"
)
;
/**
* Enables --harmony flags programmatically.
*
@param
{
Array.<string>
} [flags] Flags to enable, defaults to just `harmony`
*
@returns
{
undefined
}
*
@property
{
Array.<string>
} enabled Enabled flags
*
@property
{
Array.<string>
} supported Supported flags
*/
function
harmonize
(
flags
)
{
// assume to be the spawned child if there are any enabled flags
if
(
harmonize
.
enabled
.
length
)
return
;
// default to just "harmony"
if
(
!
Array
.
isArray
(
flags
)
)
flags
=
[
"harmony"
]
;
// filter out unsupported flags while adding hyphens
for
(
var
i
=
0
;
i
<
flags
.
length
;
)
{
if
(
harmonize
.
supported
.
indexOf
(
flags
[
i
]
)
<
0
)
flags
.
splice
(
i
,
1
)
;
else
flags
[
i
]
=
"--"
+
flags
[
i
++
]
;
}
// now just spawn a child with inherited stdio using the specified flags
child_process
.
spawn
(
process
.
argv
[
0
]
,
flags
.
concat
(
process
.
argv
.
slice
(
1
)
)
,
{
stdio
:
'inherit'
}
)
.
on
(
"close"
,
function
(
code
)
{
process
.
exit
(
code
)
;
}
)
;
// and interrupt process flow in the parent (do not try this at home!)
process
.
once
(
"uncaughtException"
,
function
(
e
)
{
}
)
;
throw
"harmony"
;
}
;
// Get enabled flags
harmonize
.
enabled
=
(
function
(
)
{
var
flags
=
[
]
;
for
(
var
i
=
0
,
match
;
i
<
process
.
execArgv
.
length
;
++
i
)
if
(
match
=
/
\-
\-
(
h
a
r
m
o
n
y
[
\w
\-
]
*
)
/
.
exec
(
process
.
execArgv
[
i
]
)
)
flags
.
push
(
match
[
1
]
)
;
return
flags
;
}
)
(
)
;
// Get supported flags
harmonize
.
supported
=
(
function
(
)
{
var
flags
=
[
]
;
var
output
=
child_process
.
spawnSync
(
process
.
argv
[
0
]
,
[
"--v8-options"
]
)
.
output
.
toString
(
"utf8"
)
;
for
(
var
re
=
/
\-
\-
(
h
a
r
m
o
n
y
[
\w
\-
]
*
)
/
g
,
match
;
match
=
re
.
exec
(
output
)
;
)
flags
.
push
(
match
[
1
]
)
;
return
flags
;
}
)
(
)
;
Back
|
FazBrowse Home
|
New Git URL