mirror of
https://github.com/kanaka/mal.git
synced 2024-09-21 18:48:12 +03:00
c9de2e82ed
- tests/docker/Dockerfile: specifies full docker image containing all tools/languages (except matlab). - tests/docker-build.sh: build above image. - tests/docker-run.sh: launch above image. Example: ./tests/docker-run.sh make test^js^step2 - Various fixes across multiple languages: - Unicode fixes for bash and R on Ubuntu Utopic - readline history fixes for when ~/.mal-history is not available or readable/writable. No fatal errors. - fixes to work with perl 5.20 (and still perl 5.18)
40 lines
955 B
CoffeeScript
40 lines
955 B
CoffeeScript
# IMPORTANT: choose one
|
|
RL_LIB = "libreadline" # NOTE: libreadline is GPL
|
|
#RL_LIB = "libedit"
|
|
|
|
HISTORY_FILE = require('path').join(process.env.HOME, '.mal-history')
|
|
|
|
rlwrap = {} # namespace for this module in web context
|
|
|
|
ffi = require('ffi')
|
|
fs = require('fs')
|
|
|
|
rllib = ffi.Library(RL_LIB, {
|
|
'readline': ['string', ['string']],
|
|
'add_history': ['int', ['string']]})
|
|
|
|
rl_history_loaded = false
|
|
|
|
exports.readline = rlwrap.readline = (prompt = 'user> ') ->
|
|
if !rl_history_loaded
|
|
rl_history_loaded = true
|
|
lines = []
|
|
if fs.existsSync(HISTORY_FILE)
|
|
lines = fs.readFileSync(HISTORY_FILE).toString().split("\n");
|
|
|
|
# Max of 2000 lines
|
|
lines = lines[Math.max(lines.length - 2000, 0)..]
|
|
rllib.add_history(line) for line in lines when line != ""
|
|
|
|
line = rllib.readline prompt
|
|
if line
|
|
rllib.add_history line
|
|
try
|
|
fs.appendFileSync HISTORY_FILE, line + "\n"
|
|
catch exc
|
|
true
|
|
|
|
line
|
|
|
|
# vim: ts=2:sw=2
|