Skip to content

Update to PureScript v0.15.0 #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": "eslint:recommended",
"env": {
"commonjs": true
"node": true
},
"rules": {
"strict": [2, "global"],
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"

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

- name: Install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
## [Unreleased]

Breaking changes:
- Update project and deps to PureScript v0.15.0 (#31 by @JordanMartinez, @thomashoneyman, @sigma-andex)

New features:

Expand Down
20 changes: 10 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"package.json"
],
"dependencies": {
"purescript-exceptions": "^5.0.0",
"purescript-foreign": "^6.0.0",
"purescript-foreign-object": "^3.0.0",
"purescript-functions": "^5.0.0",
"purescript-node-fs": "^6.0.0",
"purescript-node-streams": "^5.0.0",
"purescript-nullable": "^5.0.0",
"purescript-posix-types": "^5.0.0",
"purescript-unsafe-coerce": "^5.0.0"
"purescript-exceptions": "master",
"purescript-foreign": "master",
"purescript-foreign-object": "master",
"purescript-functions": "master",
"purescript-node-fs": "master",
"purescript-node-streams": "master",
"purescript-nullable": "main",
"purescript-posix-types": "master",
"purescript-unsafe-coerce": "master"
},
"devDependencies": {
"purescript-console": "^5.0.0"
"purescript-console": "master"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
"devDependencies": {
"eslint": "^7.15.0",
"pulp": "^15.0.0",
"purescript-psa": "^0.8.0",
"pulp": "16.0.0-0",
"purescript-psa": "^0.8.2",
"rimraf": "^3.0.2"
}
}
182 changes: 69 additions & 113 deletions src/Node/ChildProcess.js
Original file line number Diff line number Diff line change
@@ -1,140 +1,96 @@
"use strict";

/* eslint-env node*/

exports.unsafeFromNullable = function unsafeFromNullable(msg) {
return function (x) {
import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from "child_process";

export function unsafeFromNullable(msg) {
return 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);
};
};
};
};
export function spawnImpl(command) {
return args => opts => () => 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)();
}
);
};
};
};
};
export function execImpl(command) {
return opts => callback => () => exec(
command,
opts,
(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)();
}
);
};
};
};
};
export const execFileImpl = function execImpl(command) {
return args => opts => callback => () => execFile(
command,
args,
opts,
(err, stdout, stderr) => {
callback(err)(stdout)(stderr)();
}
);
};

exports.execSyncImpl = function execSyncImpl(command) {
return function (opts) {
return function () {
return require("child_process").execSync(command, opts);
};
};
};
export function execSyncImpl(command) {
return opts => () => execSync(command, opts);
}

exports.execFileSyncImpl = function execFileSyncImpl(command) {
return function (args) {
return function (opts) {
return function () {
return require("child_process").execFileSync(command, args, opts);
};
};
};
};
export function execFileSyncImpl(command) {
return args => opts => () => execFileSync(command, args, opts);
}

exports.fork = function fork(cmd) {
return function (args) {
return function () {
return require("child_process").fork(cmd, args);
};
};
};
export function fork(cmd) {
return args => () => cp_fork(cmd, args);
}

exports.mkOnExit = function mkOnExit(mkChildExit) {
export function mkOnExit(mkChildExit) {
return function onExit(cp) {
return function (cb) {
return function () {
cp.on("exit", function (code, signal) {
cb(mkChildExit(code)(signal))();
});
};
return cb => () => {
cp.on("exit", (code, signal) => {
cb(mkChildExit(code)(signal))();
});
};
};
};
}

exports.mkOnClose = function mkOnClose(mkChildExit) {
export function mkOnClose(mkChildExit) {
return function onClose(cp) {
return function (cb) {
return function () {
cp.on("close", function (code, signal) {
cb(mkChildExit(code)(signal))();
});
};
};
};
};

exports.onDisconnect = function onDisconnect(cp) {
return function (cb) {
return function () {
cp.on("disconnect", cb);
return cb => () => {
cp.on("close", (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)();
});
};
};
};
export function onDisconnect(cp) {
return cb => () => {
cp.on("disconnect", cb);
};
};
}

exports.onError = function onError(cp) {
return function (cb) {
return function () {
cp.on("error", function (err) {
cb(err)();
export function mkOnMessage(nothing) {
return just => (function onMessage(cp) {
return cb => () => {
cp.on("message", (mess, sendHandle) => {
cb(mess, sendHandle ? just(sendHandle) : nothing)();
});
};
});
}

export function onError(cp) {
return cb => () => {
cp.on("error", err => {
cb(err)();
});
};
};
}

exports.undefined = undefined;
exports.process = process;
const _undefined = undefined;
export { _undefined as undefined };
import process from "process";
export { process };