purs
v0.3.0
Published
Spawn a new process using PureScript CLI
Downloads
22
Maintainers
Readme
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 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 aPromise
for a resultObject
withstdout
andstderr
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