JSPM

  • Created
  • Published
  • Downloads 234
  • Score
    100M100P100Q84065F
  • License MIT

Install PureScript to a given directory

Package Exports

  • install-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 (install-purescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

install-purescript

NPM version Build Status Build status Coverage Status

Install PureScript to a given directory

const {readdirSync} = require('fs');
const {spwan} = require('child_process');
const downloadOrBuildPurescript = require('install-purescript');

downloadOrBuildPurescript('./dest', {version: '0.11.4'}).subscribe({
  complete() {
    readdirSync('dest'); //=> ['purs']
    spwan('./dest/purs', ['--version'], (err, stdout) => {
      stdout.toString(); //=> '0.11.4\n'
    });
  }
});

Installation

Use npm.

npm install install-purescript

API

const downloadOrBuildPurescript = require('install-purescript');

downloadOrBuildPurescript(dir [, options])

path: String (directory path)
options: Object
Return: Observable ()

head ────────────×─┬─ check-stack ─────×─┐
 │                 │   │                 │
 ○                 │   ○                 │
 │                 │   │                 │
download-binary ─×─┤  download-source ─×─┤
 │                 │   │                 │
 ○                 │   ○                 │
 │                 │   │                 │
check-binary ────×─┘  setup ───────────×─┤
 │                     │                 │
 │                     ○                 │
 │                     │                 │
 │                    build ───────────×─│
 │                     │                 │
 ○                     ○                 │
 │                     │                 │
╔════════════╗        ╔═════════════╗   ╔════════╗
║ Downloaded ║        ║ Built       ║   ║ Failed ║
║ a prebuilt ║        ║ a binary    ║   ╚════════╝   
║ binary     ║        ║ from source ║
╚════════════╝        ╚═════════════╝

Similar to Node.js built-in fs.readdir, but different in the following points:

  • Returns a Promise
  • Doesn't support encoding option
  • The result is sorted based on String#localeCompare()

Options

locale property will be passed to the second argument of String#localeCompare(), and the rest will be used in the third argument.

readdirSorted('/path/to/dir').then(paths => {
  paths; /* => ['10', '2', 'ä', 'z'] */
});

readdirSorted('/path/to/dir', {
  locale: 'sv',
  numeric: true
}).then(paths => {
  paths; /* => ['2', '10', 'z', 'ä'] */
});

License

Copyright (c) 2017 Shinnosuke Watanabe

Licensed under the MIT License.