From 5c09f732347fd5a5c4ac0584fcaf58e4b0021b4f Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Wed, 5 Apr 2017 08:43:17 -0700 Subject: [PATCH] Updates for 0.11 (#10) * Updates for 0.11 * eslint * Remove test script, eslint --fix * Add .eslintrc --- .eslintrc | 39 +++++++++++ .gitignore | 3 +- .jscsrc | 17 ----- .jshintrc | 19 ------ .travis.yml | 2 - bower.json | 20 +++--- package.json | 12 ++-- src/Node/ChildProcess.js | 134 ++++++++++++++++++------------------- src/Node/ChildProcess.purs | 10 +-- test/Main.purs | 4 +- 10 files changed, 129 insertions(+), 131 deletions(-) create mode 100644 .eslintrc delete mode 100644 .jscsrc delete mode 100644 .jshintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..1a45f8b --- /dev/null +++ b/.eslintrc @@ -0,0 +1,39 @@ +{ + "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/.gitignore b/.gitignore index e306283..9abba98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /.* !/.gitignore -!/.jscsrc -!/.jshintrc +!/.eslintrc !/.travis.yml /bower_components/ /node_modules/ diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 2561ce9..0000000 --- a/.jscsrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "preset": "grunt", - "disallowSpacesInFunctionExpression": null, - "requireSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInAnonymousFunctionExpression": null, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInsideObjectBrackets": null, - "requireSpacesInsideObjectBrackets": "all", - "validateQuoteMarks": "\"", - "requireCurlyBraces": null -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index e73b39a..0000000 --- a/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "bitwise": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "funcscope": true, - "futurehostile": true, - "strict": "global", - "latedef": true, - "noarg": true, - "nocomma": true, - "nonew": true, - "notypeof": true, - "singleGroups": true, - "undef": true, - "unused": true, - "eqnull": true, - "predef": ["exports", "require", "process"] -} diff --git a/.travis.yml b/.travis.yml index 969f56d..7f976a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ install: script: - bower install --production - npm run -s build - - bower install - - npm test after_success: - >- test $TRAVIS_TAG && diff --git a/bower.json b/bower.json index a76eec9..3c9949b 100644 --- a/bower.json +++ b/bower.json @@ -16,17 +16,17 @@ "package.json" ], "dependencies": { - "purescript-exceptions": "^2.0.0", - "purescript-foreign": "^3.0.0", - "purescript-functions": "^2.0.0", - "purescript-maps": "^2.0.0", - "purescript-node-fs": "^3.0.0", - "purescript-node-streams": "^2.0.0", - "purescript-nullable": "^2.0.0", - "purescript-posix-types": "^2.0.0", - "purescript-unsafe-coerce": "^2.0.0" + "purescript-exceptions": "^3.0.0", + "purescript-foreign": "^4.0.0", + "purescript-functions": "^3.0.0", + "purescript-maps": "^3.0.0", + "purescript-node-fs": "^4.0.0", + "purescript-node-streams": "^3.0.0", + "purescript-nullable": "^3.0.0", + "purescript-posix-types": "^3.0.0", + "purescript-unsafe-coerce": "^3.0.0" }, "devDependencies": { - "purescript-console": "^2.0.0" + "purescript-console": "^3.0.0" } } diff --git a/package.json b/package.json index 8e20023..276a84c 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,13 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "jshint src && jscs src && pulp build --censor-lib --strict", - "test": "pulp test" + "build": "eslint src && pulp build -- --censor-lib --strict" }, "devDependencies": { - "jscs": "^3.0.7", - "jshint": "^2.9.4", - "pulp": "^9.0.1", - "purescript-psa": "^0.3.9", - "purescript": "^0.10.1", + "eslint": "^3.17.1", + "pulp": "^11.0.0", + "purescript-psa": "^0.5.0", + "purescript": "^0.11.1", "rimraf": "^2.5.4" } } diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 977c392..57ebab6 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -1,112 +1,112 @@ -"use strict"; +'use strict'; /* eslint-env node*/ exports.unsafeFromNullable = function unsafeFromNullable (msg) { - return function (x) { - if (x === null) throw new Error(msg); - return x; - }; + 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); - }; + return function (args) { + return function (opts) { + return function () { + return require('child_process').spawn(command, args, opts); + }; + }; }; - }; }; 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)(); - }); - }; + return function (opts) { + return function (callback) { + return function () { + return require('child_process').exec(command, opts, function (err, stdout, stderr) { + callback(err)(stdout)(stderr)(); + }); + }; + }; }; - }; }; 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)(); - }); + 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.fork = function fork (cmd) { - return function (args) { - return function () { - return require("child_process").fork(cmd, args); + return function (args) { + return function () { + return require('child_process').fork(cmd, args); + }; }; - }; }; exports.mkOnExit = function mkOnExit (mkChildExit) { - return function onExit (cp) { - return function (cb) { - return function () { - cp.on("exit", function (code, signal) { - cb(mkChildExit(code)(signal))(); - }); - }; + return function onExit (cp) { + return function (cb) { + return function () { + cp.on('exit', function (code, signal) { + cb(mkChildExit(code)(signal))(); + }); + }; + }; }; - }; }; exports.mkOnClose = function mkOnClose (mkChildExit) { - return function onClose (cp) { - return function (cb) { - return function () { - cp.on("exit", function (code, signal) { - cb(mkChildExit(code)(signal))(); - }); - }; + return function onClose (cp) { + return function (cb) { + return function () { + cp.on('exit', function (code, signal) { + cb(mkChildExit(code)(signal))(); + }); + }; + }; }; - }; }; exports.onDisconnect = function onDisconnect (cp) { - return function (cb) { - return function () { - cp.on("disconnect", cb); + return function (cb) { + return function () { + cp.on('disconnect', cb); + }; }; - }; }; 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)(); - }); + 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.onError = function onError (cp) { - return function (cb) { - return function () { - cp.on("error", function (err) { - cb(err)(); - }); + return function (cb) { + return function () { + cp.on('error', function (err) { + cb(err)(); + }); + }; }; - }; }; exports.undefined = undefined; diff --git a/src/Node/ChildProcess.purs b/src/Node/ChildProcess.purs index 2bcef65..4a3339d 100644 --- a/src/Node/ChildProcess.purs +++ b/src/Node/ChildProcess.purs @@ -48,7 +48,7 @@ module Node.ChildProcess import Prelude import Control.Alt ((<|>)) -import Control.Monad.Eff (Eff) +import Control.Monad.Eff (kind Effect, Eff) import Control.Monad.Eff.Exception as Exception import Control.Monad.Eff.Exception.Unsafe (unsafeThrow) @@ -68,10 +68,10 @@ import Node.Stream (Readable, Writable, Stream) import Unsafe.Coerce (unsafeCoerce) -- | A handle for inter-process communication (IPC). -foreign import data Handle :: * +foreign import data Handle :: Type -- | The effect for creating and interacting with child processes. -foreign import data CHILD_PROCESS :: ! +foreign import data CHILD_PROCESS :: Effect newtype ChildProcess = ChildProcess ChildProcessRec @@ -283,7 +283,7 @@ foreign import execFileImpl -> (Nullable Exception.Error -> Buffer -> Buffer -> Eff (cp :: CHILD_PROCESS | eff) Unit) -> Eff (cp :: CHILD_PROCESS | eff) Unit -foreign import data ActualExecOptions :: * +foreign import data ActualExecOptions :: Type convertExecOptions :: ExecOptions -> ActualExecOptions convertExecOptions opts = unsafeCoerce @@ -376,7 +376,7 @@ foreign import process :: forall props. { | props } ignore :: Array (Maybe StdIOBehaviour) ignore = map Just [Ignore, Ignore, Ignore] -foreign import data ActualStdIOBehaviour :: * +foreign import data ActualStdIOBehaviour :: Type toActualStdIOBehaviour :: StdIOBehaviour -> ActualStdIOBehaviour toActualStdIOBehaviour b = case b of diff --git a/test/Main.purs b/test/Main.purs index 61cdea7..0b42e81 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -13,7 +13,7 @@ import Node.ChildProcess (CHILD_PROCESS, Exit(..), defaultExecOptions, exec, onE import Node.Encoding (Encoding(UTF8)) import Node.Stream (onData) -type TestEff = Eff (cp :: CHILD_PROCESS, console :: CONSOLE, err :: EXCEPTION, buffer :: Buffer.BUFFER) Unit +type TestEff = Eff (cp :: CHILD_PROCESS, console :: CONSOLE, exception :: EXCEPTION, buffer :: Buffer.BUFFER) Unit main :: TestEff main = do @@ -36,7 +36,7 @@ main = do log "kills processes" spawn "ls" ["-la"] defaultSpawnOptions >>= \ls -> do - kill SIGTERM ls + _ <- kill SIGTERM ls onExit ls \exit -> case exit of BySignal SIGTERM ->