|
|
|
@ -192,6 +192,7 @@ func (c *Console) init(preload []string) error { |
|
|
|
|
if obj := admin.Object(); obj != nil { // make sure the admin api is enabled over the interface
|
|
|
|
|
obj.Set("sleepBlocks", bridge.SleepBlocks) |
|
|
|
|
obj.Set("sleep", bridge.Sleep) |
|
|
|
|
obj.Set("clearHistory", c.clearHistory) |
|
|
|
|
} |
|
|
|
|
// Preload any JavaScript files before starting the console
|
|
|
|
|
for _, path := range preload { |
|
|
|
@ -216,6 +217,16 @@ func (c *Console) init(preload []string) error { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (c *Console) clearHistory() { |
|
|
|
|
c.history = nil |
|
|
|
|
c.prompter.ClearHistory() |
|
|
|
|
if err := os.Remove(c.histPath); err != nil { |
|
|
|
|
fmt.Fprintln(c.printer, "can't delete history file:", err) |
|
|
|
|
} else { |
|
|
|
|
fmt.Fprintln(c.printer, "history file deleted") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// consoleOutput is an override for the console.log and console.error methods to
|
|
|
|
|
// stream the output into the configured output stream instead of stdout.
|
|
|
|
|
func (c *Console) consoleOutput(call otto.FunctionCall) otto.Value { |
|
|
|
|