purs

0.3.0 • Public • Published

purs

npm version Build Status Coverage Status

Spawn a new process using PureScript CLI

const {readFile} = require('purs').promises;
const purs = require('purs');
 
(async () => {
  await purs.compile(['source.purs', '--output', 'out']);
  await readFile('out/Main/index.js', 'utf8'); //=> '// Generated by purs ...'
})();

Installation

Use npm.

npm install purs

Since this package contains purescript npm package in its dependency list and uses it when spawning a new process, there is no need to install PureScript separately.

API

const purs = require('purs');

purs.help([options]), purs.version([options])

options: Object (execa options)
Return: Promise<string>

Spawn a new purs --help or purs --version process and return a Promise of the command stdout as a string.

(async () => {
  await purs.help(); //=> 'Usage: purs.bin COMMAND\n  The PureScript compiler ...'
})();

purs.bundle([args][, options]), purs.compile([args][, options]), purs.docs([args][, options]), purs.hierarchy([args][, options]), purs.ide([args][, options]), purs.publish([args][, options])

args: Array<string> (additional command-line arguments)
options: Object (execa options)
Return: ChildProcess with additional execa-specific enhancement

Spawn a new process with a purs subcommand corresponding to the method name and return a execa return value:

a child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

(async () => {
  const result = await purs.bundle(['index.js', '--output', 'app.js']);
  /*=> {
    stdout: '',
    stderr: '',
    code: 0,
    failed: false,
    killed: false,
    signal: null,
    cmd: '/Users/example/node_modules/purescript/purs.bin bundle index.js --output app.js',
    timedOut: false
  } */
})();

License

ISC License © 2018 Shinnosuke Watanabe

Package Sidebar

Install

npm i purs

Weekly Downloads

29

Version

0.3.0

License

ISC

Unpacked Size

5.99 kB

Total Files

4

Last publish

Collaborators

  • shinnn