Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .eslintrc

This file was deleted.

28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"parserOptions": {
"ecmaVersion": 5
},
"extends": "eslint:recommended",
"env": {
"commonjs": true
},
"rules": {
"strict": [2, "global"],
"block-scoped-var": 2,
"consistent-return": 2,
"eqeqeq": [2, "smart"],
"guard-for-in": 2,
"no-caller": 2,
"no-extend-native": 2,
"no-loop-func": 2,
"no-new": 2,
"no-param-reassign": 2,
"no-return-assign": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"radix": [2, "always"],
"indent": [2, 2],
"quotes": [2, "double"],
"semi": [2, "always"]
}
}
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main

- uses: actions/setup-node@v1
with:
node-version: "10"

- name: Install dependencies
run: |
npm install -g bower
npm install
bower install --production

- name: Build source
run: npm run-script build

- name: Run tests
run: |
bower install
npm run-script test --if-present
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/.*
!/.gitignore
!/.eslintrc
!/.travis.yml
!/.eslintrc.json
!/.github/
/bower_components/
/node_modules/
/output/
package-lock.json
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# purescript-node-readline

[![Latest release](http://img.shields.io/github/release/purescript-node/purescript-node-readline.svg)](https://github.com/purescript-node/purescript-node-readline/releases)
[![Build Status](https://travis-ci.org/purescript-node/purescript-node-readline.svg?branch=master)](https://travis-ci.org/purescript-node/purescript-node-readline)
[![Build status](https://github.com/purescript-node/purescript-node-readline/workflows/CI/badge.svg?branch=master)](https://github.com/purescript-node/purescript-node-readline/actions?query=workflow%3ACI+branch%3Amaster)
[![Pursuit](https://pursuit.purescript.org/packages/purescript-node-readline/badge)](https://pursuit.purescript.org/packages/purescript-node-readline)

A low-level PureScript interface to the Node `readline` API.

## Installation

```
bower install purescript-node-readline
spago install node-readline
```

Module documentation can be found on [Pursuit](https://pursuit.purescript.org/packages/purescript-node-readline)
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"build": "eslint src && pulp build -- --censor-lib --strict"
},
"devDependencies": {
"eslint": "^3.17.1",
"pulp": "^11.0.0",
"purescript-psa": "^0.5.0",
"rimraf": "^2.5.4"
"eslint": "^7.15.0",
"pulp": "^15.0.0",
"purescript-psa": "^0.8.0",
"rimraf": "^3.0.2"
}
}
83 changes: 42 additions & 41 deletions src/Node/ReadLine.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
/* global exports */
'use strict';
"use strict";

// module Node.ReadLine

exports.createInterfaceImpl = function (options) {
return function () {
var readline = require('readline');
return readline.createInterface(
{ input: options.input
, output: options.output
, completer: options.completer && function (line) {
return function () {
var readline = require("readline");
return readline.createInterface({
input: options.input,
output: options.output,
completer:
options.completer &&
function (line) {
var res = options.completer(line)();
return [res.completions, res.matched];
}
, terminal: options.terminal
, historySize: options.historySize
});
};
},
terminal: options.terminal,
historySize: options.historySize,
});
};
};

exports.close = function (readline) {
return function () {
readline.close();
};
return function () {
readline.close();
};
};

exports.prompt = function (readline) {
return function () {
readline.prompt();
};
return function () {
readline.prompt();
};
};

exports.question = function(text) {
return function(callback) {
return function(readline) {
return function() {
readline.question(text, function(result) {
callback(result)();
});
};
};
exports.question = function (text) {
return function (callback) {
return function (readline) {
return function () {
readline.question(text, function (result) {
callback(result)();
});
};
};
};
};

exports.setPrompt = function (prompt) {
return function (length) {
return function (readline) {
return function () {
readline.setPrompt(prompt, length);
};
};
return function (length) {
return function (readline) {
return function () {
readline.setPrompt(prompt, length);
};
};
};
};

exports.setLineHandler = function (readline) {
return function (callback) {
return function () {
readline.removeAllListeners('line');
readline.on('line', function (line) {
callback(line)();
});
};
return function (callback) {
return function () {
readline.removeAllListeners("line");
readline.on("line", function (line) {
callback(line)();
});
};
};
};