download-or-build-purescript
First try to download a prebuilt PureScript binary, then build from a source if the prebuilt one is unavailable
const readdir = promise;const execFile = ;const downloadOrBuildPurescript = ; ;
Installation
npm install download-or-build-purescript
API
const downloadOrBuildPurescript = ;
downloadOrBuildPurescript([options])
options: Object
Return: Observable
(Kevin Smith's implementation)
When the Observable
is subscribed,
- it downloads a prebuilt PureScript binary from the PureScript release page
- if a prebuilt binary is not available, it downloads the PureScript source code and builds a binary form it
- it puts the binary at the current working directory
while successively sending events to its Observer
.
Events
Each event object has id
property with one of these values:
head
head:fail
head:complete
download-binary
download-binary:fail
download-binary:complete
check-binary
check-binary:fail
check-binary:complete
check-stack
check-stack:complete
download-source
download-source:complete
setup
setup:complete
build
build:complete
head ------------ x -+- check-stack ----- x -+
| | | |
o | o |
| | | |
download-binary - x -+ download-source - x -+
| | | |
o | o |
| | | |
check-binary ---- x -+ setup ----------- x -+
| | |
| o |
| | |
| build ----------- x -+
| | |
o o |
| | |
***************** ***************** ^^^^^^^
Downloaded a Built a binary Error
prebuilt binary from the source ^^^^^^^
***************** *****************
head
Fires when it starts to check if a prebuilt binary is provided for the current platform.
id: 'head'
head:fail
Fires when it cannot start downloading the binary, for example no prebuilt ones are provided for the current platform.
id: 'head:fail' error: <Error>
head:complete
Fires when it confirms that a prebuilt binary is provided for the current platform.
id: 'head:complete'
download-binary
Fires many times while downloading and extracting the prebuilt binary.
entry
and response
properties are derived from dl-tar
.
id: 'download-binary' entry: <ReadEntry> response: bytes: <number> headers: <Object> url: <string>
download-binary:fail
Fires when it fails to download the binary somehow.
id: 'download-binary:fail' error: <Error>
download-binary:complete
Fires when the prebuilt binary is successfully downloaded.
id: 'download-binary:complete'
check-binary
Fires when it starts to verify the downloaded prebuilt binary works correctly, by running purs --version
.
id: 'check-binary'
check-binary:fail
Fires when the downloaded binary doesn't work correctly.
id: 'check-binary:fail' error: <Error>
check-binary:complete
Fires when it verifies the downloaded binary works correctly.
id: 'check-binary:complete'
check-stack
Fires after one of these events: head:fail
download-binary:fail
check-binary:fail
.
path
property is the absolute path of the stack
command, and version
property is its version.
id: 'check-stack' path: <string> version: <string>
check-stack:complete
Fires after making sure the stack
command is installed in your $PATH
.
id: 'check-binary:complete'
download-source
Fires many times while downloading and extracting the PureScript source code.
entry
and response
properties are derived from dl-tar
.
id: 'download-source' entry: <ReadEntry> response: bytes: <number> headers: <Object> url: <string>
download-source:complete
Fires when the source code is successfully downloaded.
id: 'download-source'
setup
setup:complete
build
build:complete
Inherited from build-purescript
.
Errors
Every error passed to the Observer
has id
property that indicates which step the error occurred at.
// When the `stack` command is not installed; // When your machine lose the internet connection while downloading the source;
Options
Options are directly passed to download-purescript
and build-purescript
. Note that,
filter
option is not supported.revision
option is not supported. Useversion
option instead.
Additionally, you can use the following:
rename
Type: Function
Default: v => v
Receives the original binary name (purs
on POSIX, purs.exe
on Windows) and modifies the binary name to its return value.
const extname = ; ;
License
ISC License © 2017 - 2019 Shinnosuke Watanabe