factor out ERROR regex

This commit is contained in:
Anton Dyudin 2018-03-09 12:47:45 -08:00
parent 31715d7d36
commit 4bf1f38a67
3 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,10 @@
require! <[ split ]>
{through} = require 'promise-streams'
{Urbit} = require './runner.ls'
{Urbit,ERROR} = require './runner.ls'
urbit = new Urbit process.argv[2 to]
urbit.expect-error!then -> process.exit 1
urbit.expect ERROR .then -> process.exit 1
<- urbit.expect /dojo> / .then

View File

@ -1,6 +1,7 @@
require! <[ stream-snitch colors escape-string-regexp ]>
pty = require \pty.js
export ERROR = /(ford: |\r\x1b\[K\/~)/
export class Urbit
(args)->
@stdout = process.stdout # overridable
@ -24,9 +25,7 @@ export class Urbit
, 200
expect: (re)~>
new Promise (resolve)~>
#@listeners.push
@pty.pipe (new stream-snitch re).once "match" resolve
expect-error: -> @expect /(ford: |\r\x1b\[K\/~)/ #ALT if-error
@pty.pipe (new stream-snitch re).once "match" resolve
expect-immediate: (re)->
Promise.race [
@expect re

View File

@ -1,11 +1,11 @@
{Urbit} = require './runner.ls'
{Urbit,ERROR} = require './runner.ls'
urbit = new Urbit <[-B urbit.pill -A .. -cFI zod zod]>
Promise.resolve urbit
.then (urb)->
urb.note "Booting urbit"
Promise.race [
urb.expect-error!then ->
urb.expect ERROR .then ->
urb.warn "Error detected"
throw Error "Stack trace while booting"
, do