Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ok1kvk.cz
content
Commits
dbf08282
Commit
dbf08282
authored
Jan 11, 2020
by
Isabella Skořepová
Browse files
Fix end and possible race conditions
parent
394b33a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
index.js
View file @
dbf08282
...
...
@@ -2,33 +2,32 @@
const
{
spawnSync
,
spawn
}
=
require
(
'
child_process
'
)
const
config
=
require
(
'
./sitegin/config
'
)
function
onBabelExit
(
code
)
{
setTimeout
(()
=>
{
runBabel
({
watch
:
true
})
},
500
)
}
function
runBabel
({
watch
=
false
})
{
function
runBabel
({
onExit
,
opts
=
[]
})
{
const
babel
=
spawn
(
'
./node_modules/.bin/babel
'
,
[
'
theme-source
'
,
'
-d
'
,
'
theme
'
,
'
--delete-dir-on-start
'
,
watch
?
'
--watch
'
:
null
,
].
filter
(
a
=>
a
),
[
'
theme-source
'
,
'
-d
'
,
'
theme
'
,
...
opts
].
filter
(
a
=>
a
),
{
stdio
:
'
inherit
'
,
cwd
:
__dirname
},
)
if
(
watch
)
babel
.
on
(
'
exit
'
,
onBabelExit
)
if
(
onExit
)
babel
.
on
(
'
exit
'
,
onExit
)
}
function
runBabelWatch
()
{
runBabel
({
onExit
:
()
=>
{
setTimeout
(()
=>
runBabelWatch
(),
500
)
},
opts
:
[
'
--skip-initial-build
'
,
'
--watch
'
],
})
}
;(
async
()
=>
{
const
opts
=
await
config
()
runBabel
({
watch
:
!
opts
.
nowatch
})
if
(
opts
.
config
.
options
.
nowatch
)
{
require
(
'
./sitegin/index.js
'
)
}
else
{
await
new
Promise
(
res
=>
runBabel
({
onExit
:
res
,
opts
:
[
'
--delete-dir-on-start
'
]
}),
)
const
watch
=
!
opts
.
config
.
options
.
nowatch
if
(
watch
)
{
runBabelWatch
()
spawnSync
(
process
.
argv
[
0
],
[
...
...
@@ -40,5 +39,7 @@ function runBabel({ watch = false }) {
],
{
stdio
:
[
'
inherit
'
,
'
inherit
'
,
'
inherit
'
]
},
)
}
else
{
require
(
'
./sitegin/index.js
'
)
}
})()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment