purs v0.3.0
purs
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
npm install pursSince 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), purs.compile(args), purs.docs(args), purs.hierarchy(args), purs.ide(args), purs.publish(args)
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_processinstance, which is enhanced to also be aPromisefor a resultObjectwithstdoutandstderrproperties.
(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