diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 1a45f8b..0000000 --- a/.eslintrc +++ /dev/null @@ -1,39 +0,0 @@ -{ - "env": { - "node": true, - }, - "rules": { - "valid-jsdoc": [2, { - "prefer": { "return": "returns" }, - "requireReturn": true, - "requireParamDescription": true, - "requireReturnDescription": false - }], - "camelcase": 1, - "no-multi-spaces": 0, - "comma-spacing": 1, - "comma-style": [2, "first"], - "consistent-return": 0, - "eol-last": 1, - "indent": [1, 4], - "no-use-before-define": [2, "nofunc"], - "no-process-exit": 0, - "no-trailing-spaces": 1, - "no-underscore-dangle": 0, - "no-unused-vars": 1, - "space-infix-ops": 1, - "quotes": [1, "single"], - "semi": [1, "always"], - "semi-spacing": 1, - "strict": [2, "global"], - "yoda": [1, "never"] - }, - "globals": { - "describe": true, - "it": true, - "before": true, - "beforeEach": true, - "after": true, - "afterEach": true - } -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..84cef4f --- /dev/null +++ b/.eslintrc.json @@ -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"] + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..063845e --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index f4dcd31..b846b63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /.* !/.gitignore -!/.eslintrc -!/.travis.yml +!/.eslintrc.json +!/.github/ /bower_components/ /node_modules/ /output/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index be7e6e0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: node_js -dist: trusty -sudo: required -node_js: stable -env: - - PATH=$HOME/purescript:$PATH -install: - - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') - - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz - - tar -xvf $HOME/purescript.tar.gz -C $HOME/ - - chmod a+x $HOME/purescript - - npm install -g bower - - npm install -script: - - bower install --production - - npm run -s build -after_success: -- >- - test $TRAVIS_TAG && - echo $GITHUB_TOKEN | pulp login && - echo y | pulp publish --no-push diff --git a/README.md b/README.md index e116c56..53fef45 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # purescript-node-child-process [![Latest release](http://img.shields.io/github/release/purescript-node/purescript-node-child-process.svg)](https://github.com/purescript/purescript-node-child-process/releases) -[![Build Status](https://travis-ci.org/purescript-node/purescript-node-child-process.svg?branch=master)](https://travis-ci.org/purescript-node/purescript-node-child-process) +[![Build status](https://github.com/purescript-node/purescript-node-child-process/workflows/CI/badge.svg?branch=master)](https://github.com/purescript-node/purescript-node-child-process/actions?query=workflow%3ACI+branch%3Amaster) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-node-child-process/badge)](https://pursuit.purescript.org/packages/purescript-node-child-process) Bindings to Node's `child_process` API. ## Installation ``` -bower install purescript-node-child-process +spago install node-child-process ``` ## Documentation diff --git a/package.json b/package.json index 02e36ea..1c67b54 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "build": "eslint src && pulp build -- --censor-lib --strict" }, "devDependencies": { - "eslint": "^4.19.1", - "pulp": "^12.2.0", - "purescript-psa": "^0.6.0", - "rimraf": "^2.6.2" + "eslint": "^7.15.0", + "pulp": "^15.0.0", + "purescript-psa": "^0.8.0", + "rimraf": "^3.0.2" } } diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 39c1168..e638721 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -1,131 +1,139 @@ -'use strict'; +"use strict"; /* eslint-env node*/ -exports.unsafeFromNullable = function unsafeFromNullable (msg) { - return function (x) { - if (x === null) throw new Error(msg); - return x; - }; -}; - -exports.spawnImpl = function spawnImpl (command) { - return function (args) { - return function (opts) { - return function () { - return require('child_process').spawn(command, args, opts); - }; - }; - }; +exports.unsafeFromNullable = function unsafeFromNullable(msg) { + return function (x) { + if (x === null) throw new Error(msg); + return x; + }; }; -exports.execImpl = function execImpl (command) { +exports.spawnImpl = function spawnImpl(command) { + return function (args) { return function (opts) { - return function (callback) { - return function () { - return require('child_process').exec(command, opts, function (err, stdout, stderr) { - callback(err)(stdout)(stderr)(); - }); - }; - }; + return function () { + return require("child_process").spawn(command, args, opts); + }; }; + }; }; - -exports.execFileImpl = function execImpl (command) { - return function (args) { - return function (opts) { - return function (callback) { - return function () { - return require('child_process').execFile(command, args, opts, function (err, stdout, stderr) { - callback(err)(stdout)(stderr)(); - }); - }; - }; - }; +exports.execImpl = function execImpl(command) { + return function (opts) { + return function (callback) { + return function () { + return require("child_process").exec( + command, + opts, + function (err, stdout, stderr) { + callback(err)(stdout)(stderr)(); + } + ); + }; }; + }; }; -exports.execSyncImpl = function execSyncImpl (command) { +exports.execFileImpl = function execImpl(command) { + return function (args) { return function (opts) { + return function (callback) { return function () { - return require('child_process').execSync(command, opts); + return require("child_process").execFile( + command, + args, + opts, + function (err, stdout, stderr) { + callback(err)(stdout)(stderr)(); + } + ); }; + }; }; + }; }; -exports.execFileSyncImpl = function execFileSyncImpl (command) { - return function (args) { - return function (opts) { - return function () { - return require('child_process').execFileSync(command, args, opts); - }; - }; +exports.execSyncImpl = function execSyncImpl(command) { + return function (opts) { + return function () { + return require("child_process").execSync(command, opts); }; + }; }; -exports.fork = function fork (cmd) { - return function (args) { - return function () { - return require('child_process').fork(cmd, args); - }; +exports.execFileSyncImpl = function execFileSyncImpl(command) { + return function (args) { + return function (opts) { + return function () { + return require("child_process").execFileSync(command, args, opts); + }; }; + }; }; -exports.mkOnExit = function mkOnExit (mkChildExit) { - return function onExit (cp) { - return function (cb) { - return function () { - cp.on('exit', function (code, signal) { - cb(mkChildExit(code)(signal))(); - }); - }; - }; +exports.fork = function fork(cmd) { + return function (args) { + return function () { + return require("child_process").fork(cmd, args); }; + }; }; -exports.mkOnClose = function mkOnClose (mkChildExit) { - return function onClose (cp) { - return function (cb) { - return function () { - cp.on('close', function (code, signal) { - cb(mkChildExit(code)(signal))(); - }); - }; - }; +exports.mkOnExit = function mkOnExit(mkChildExit) { + return function onExit(cp) { + return function (cb) { + return function () { + cp.on("exit", function (code, signal) { + cb(mkChildExit(code)(signal))(); + }); + }; }; + }; }; -exports.onDisconnect = function onDisconnect (cp) { +exports.mkOnClose = function mkOnClose(mkChildExit) { + return function onClose(cp) { return function (cb) { - return function () { - cp.on('disconnect', cb); - }; + return function () { + cp.on("close", function (code, signal) { + cb(mkChildExit(code)(signal))(); + }); + }; }; + }; }; -exports.mkOnMessage = function mkOnMessage (nothing) { - return function (just) { - return function onMessage (cp) { - return function (cb) { - return function () { - cp.on('message', function (mess, sendHandle) { - cb(mess, sendHandle ? just(sendHandle) : nothing)(); - }); - }; - }; - }; +exports.onDisconnect = function onDisconnect(cp) { + return function (cb) { + return function () { + cp.on("disconnect", cb); }; + }; }; -exports.onError = function onError (cp) { - return function (cb) { +exports.mkOnMessage = function mkOnMessage(nothing) { + return function (just) { + return function onMessage(cp) { + return function (cb) { return function () { - cp.on('error', function (err) { - cb(err)(); - }); + cp.on("message", function (mess, sendHandle) { + cb(mess, sendHandle ? just(sendHandle) : nothing)(); + }); }; + }; + }; + }; +}; + +exports.onError = function onError(cp) { + return function (cb) { + return function () { + cp.on("error", function (err) { + cb(err)(); + }); }; + }; }; exports.undefined = undefined;