Commit 1757ad02 authored by Joe Haddad's avatar Joe Haddad Committed by Tim Neutkens

Drop cli-cursor dependency (#6387)

parent 414e8fab
...@@ -13,12 +13,12 @@ export default () => { ...@@ -13,12 +13,12 @@ export default () => {
evt.preventDefault() evt.preventDefault()
Router.push({ Router.push({
pathname: window.location.pathname, pathname: window.location.pathname,
query: {lang: evt.currentTarget.lang.value} query: { lang: evt.currentTarget.lang.value }
}) })
} }
return ( return (
<I18n>{({i18n}) => <I18n>{({ i18n }) =>
<form onSubmit={onSubmit}> <form onSubmit={onSubmit}>
<select key={i18n.language} name='lang' defaultValue={availableLanguages.find(lang => lang !== i18n.language)}> <select key={i18n.language} name='lang' defaultValue={availableLanguages.find(lang => lang !== i18n.language)}>
{availableLanguages.map(lang => ( {availableLanguages.map(lang => (
......
export function onExit(fn: Function) {
function exit(signal: string = '') {
try {
if (listeners.length) {
fn()
}
} finally {
while (listeners.length) {
const { event, handler } = listeners.shift()!
process.removeListener(event, handler)
}
if (signal) {
process.kill(process.pid, signal)
}
}
}
const listeners = [
{ event: 'SIGINT', handler: () => exit('SIGINT') },
{ event: 'SIGHUP', handler: () => exit('SIGHUP') },
{ event: 'SIGQUIT', handler: () => exit('SIGQUIT') },
{ event: 'SIGTERM', handler: () => exit('SIGTERM') },
{
event: 'uncaughtException',
handler: () => {
exit()
process.exit(1)
},
},
{ event: 'exit', handler: () => exit() },
]
for (const { event, handler } of listeners) {
process.on(event as any, handler)
}
}
import chalk from 'chalk' import chalk from 'chalk'
import createStore from 'unistore' import createStore from 'unistore'
import readline from 'readline' import readline from 'readline'
import cliCursor from 'cli-cursor' import { onExit } from './exit'
export type OutputState = export type OutputState =
| { bootstrap: true; appUrl: string | null } | { bootstrap: true; appUrl: string | null }
...@@ -15,8 +15,11 @@ export type OutputState = ...@@ -15,8 +15,11 @@ export type OutputState =
export const store = createStore<OutputState>({ appUrl: null, bootstrap: true }) export const store = createStore<OutputState>({ appUrl: null, bootstrap: true })
cliCursor.hide()
process.stdout.write('\n'.repeat(process.stdout.rows || 1)) process.stdout.write('\n'.repeat(process.stdout.rows || 1))
process.stdout.write('\u001b[?25l')
onExit(() => {
process.stdout.write('\u001b[?25h')
})
store.subscribe(state => { store.subscribe(state => {
readline.cursorTo(process.stdout, 0, 0) readline.cursorTo(process.stdout, 0, 0)
readline.clearScreenDown(process.stdout) readline.clearScreenDown(process.stdout)
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
"cacache": "^11.0.2", "cacache": "^11.0.2",
"case-sensitive-paths-webpack-plugin": "2.1.2", "case-sensitive-paths-webpack-plugin": "2.1.2",
"chalk": "2.4.2", "chalk": "2.4.2",
"cli-cursor": "2.1.0",
"cross-spawn": "5.1.0", "cross-spawn": "5.1.0",
"del": "3.0.0", "del": "3.0.0",
"event-source-polyfill": "0.0.12", "event-source-polyfill": "0.0.12",
...@@ -112,7 +111,6 @@ ...@@ -112,7 +111,6 @@
"@types/babel__template": "7.0.1", "@types/babel__template": "7.0.1",
"@types/babel__traverse": "7.0.3", "@types/babel__traverse": "7.0.3",
"@types/case-sensitive-paths-webpack-plugin": "2.1.2", "@types/case-sensitive-paths-webpack-plugin": "2.1.2",
"@types/cli-cursor": "2.1.0",
"@types/cross-spawn": "6.0.0", "@types/cross-spawn": "6.0.0",
"@types/etag": "1.8.0", "@types/etag": "1.8.0",
"@types/fresh": "0.5.0", "@types/fresh": "0.5.0",
......
...@@ -1526,13 +1526,6 @@ ...@@ -1526,13 +1526,6 @@
dependencies: dependencies:
"@types/webpack" "*" "@types/webpack" "*"
"@types/cli-cursor@2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@types/cli-cursor/-/cli-cursor-2.1.0.tgz#bf293a75efb7bd8a3dd020413ec41cd317e5f128"
integrity sha512-tICz3BCZI/XDB0+qbtHEyFp7JNaL9AP+HCzrH7sRdf6mO9KMnntKlPv8Dhk01nMtCod+4Xh/pjEoJWAr0A0VmQ==
dependencies:
"@types/node" "*"
"@types/cross-spawn@6.0.0": "@types/cross-spawn@6.0.0":
version "6.0.0" version "6.0.0"
resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.0.tgz#320aaf1d1a12979f1b84fe7a5590a7e860bf3a80" resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.0.tgz#320aaf1d1a12979f1b84fe7a5590a7e860bf3a80"
...@@ -3245,13 +3238,6 @@ clean-stack@^1.0.0: ...@@ -3245,13 +3238,6 @@ clean-stack@^1.0.0:
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.3.0.tgz#9e821501ae979986c46b1d66d2d432db2fd4ae31" resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.3.0.tgz#9e821501ae979986c46b1d66d2d432db2fd4ae31"
integrity sha1-noIVAa6XmYbEax1m0tQy2y/UrjE= integrity sha1-noIVAa6XmYbEax1m0tQy2y/UrjE=
cli-cursor@2.1.0, cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=
dependencies:
restore-cursor "^2.0.0"
cli-cursor@^1.0.2: cli-cursor@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987"
...@@ -3259,6 +3245,13 @@ cli-cursor@^1.0.2: ...@@ -3259,6 +3245,13 @@ cli-cursor@^1.0.2:
dependencies: dependencies:
restore-cursor "^1.0.1" restore-cursor "^1.0.1"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=
dependencies:
restore-cursor "^2.0.0"
cli-spinners@^0.1.2: cli-spinners@^0.1.2:
version "0.1.2" version "0.1.2"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-0.1.2.tgz#bb764d88e185fb9e1e6a2a1f19772318f605e31c" resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-0.1.2.tgz#bb764d88e185fb9e1e6a2a1f19772318f605e31c"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment