JSPM

  • Created
  • Published
  • Downloads 222
  • Score
    100M100P100Q70810F
  • License MIT

Build a PureScript binary from source

Package Exports

  • build-purescript

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (build-purescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

download-purescript

NPM version Build Status Coverage Status

A Node.js module to download a prebuilt PureScript binary

const {readdirSync} = require('fs');
const downloadPurescript = require('download-purescript');

downloadPurescript('./dest/').subscribe({
  complete() {
    readdirSync('./dest/');
    /* => [
      'psc',
      'psc-bundle',
      'psc-docs',
      'psc-ide-client',
      'psc-ide-server',
      'psc-package',
      'psc-publish',
      'psci'
    ] */
  }
});

Installation

Use npm.

npm install download-purescript

API

const downloadPurescript = require('download-purescript');

downloadPurescript(dir [, options])

dir: String (a directory path where the PureScript binary will be downloaded)
options: Object
Return: Observable (zenparsing's implementation)

When the observable is subscribed, it starts to download a tar.gz archive from the PureScript release page, extract it and successively send extraction progress as objects to its observer.

Every progress object have two properties header and bytes. bytes is the total size of currently extracted entry, and header is a header of the entry.

downloadPurescript('my/dir')
.filter(({bytes, header}) => bytes === header.size)
.forEach(({header}) => console.log(`${header.name}`))
.then(() => console.log('\nCompleted.'));
✓ psc
✓ psc-bundle
✓ psc-docs
✓ psc-ide-client
✓ psc-ide-server
✓ psc-package
✓ psc-publish
✓ psci

Completed.

Options

You can pass options to Request and tar-fs's extract method. Note that:

  • strip option defaults to 1, not 0. That means the top level directory is stripped off by default.
  • ignore option defaults to (_, ({mode})) => (mode & 1) !== 1, that means all the non-executavle files, for example README, won't be downloaded by default. Pass () => true to ignore option if you want to download all files included in the archive.

Additionally, you can use the following:

version

Type: String
Default: 0.10.7

Specify the version you want to download.

const {execFileSync} = require('child_process');

downloadPurescript('dir1').subscribe({
  complete() {
    execFileSync('./dir1/psc', ['--version'], {encoding: 'utf8'}).trim(); //=> '0.10.7'
  }
});

downloadPurescript('dir2', {version: '0.10.6'}).subscribe({
  complete() {
    execFileSync('./dir2/psc', ['--version'], {encoding: 'utf8'}).trim(); //=> '0.10.6'
  }
});

platform

Type: String (currently supported: darwin linux win32)
Default: process.platform

By default this module tries to download the binary for the current platform. Use this option to download the one for the different platform.

License

Copyright (c) 2017 Shinnosuke Watanabe

Licensed under the MIT License.