npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

build-purescript

v0.4.1

Published

Build a PureScript binary from source

Downloads

206

Readme

build-purescript

npm version Build Status Coverage Status

A Node.js module to build a PureScript binary from source

const {execFile} = require('child_process');
const buildPurescript = require('build-purescript');

buildPurescript().subscribe({
  complete() {
    console.log('Build completed.');

    execFile('./purs', ['--help'], (err, stdout) => {
      stdout.toString(); //=> 'Usage: purs COMMAND\n  The PureScript compiler and tools ...'
    });
  }
});

Installation

Make sure stack command is installed in your $PATH, then install build-purescript via npm CLI.

npm install build-purescript

API

const buildPurescript = require('build-purescript');

buildPurescript([options])

options: Object
Return: Observable (Kevin Smith's implementation)

When the Observable is subscribed, it starts to download PureScript source from the GitHub repository, build it and put a built binary onto the current working directory, successively sending event objects to its Observer.

Events

Each event object has id property with one of these values:

download

Sent to the Observer while downloading and extracting the PureScript source archive to the default temporary directory of the current OS.

entry and response properties are derived from dl-tar.

{
  id: 'download',
  entry: <ReadEntry>,
  response: {
    bytes: <number>,
    headers: <Object>,
    url: <string>
  }
}
download:complete

Sent to the Observer when the PureScript source is completely downloaded.

{
  id: 'download:complete'
}
setup

Sent to the Observer while running stack setup command.

command property is the command currently running, and output property is each line of stderr.

{
  id: 'setup',
  command 'stack setup ...',
  output: <string>
}
setup:complete

Sent to the Observer when stack setup command exits with code 0.

{
  id: 'setup:complete'
}
build

Sent to the Observer while running stack install command.

command property is the command currently running, and output property is each line of stderr.

{
  id: 'build',
  command 'stack install ...',
  output: <string>
}
build:complete

Sent to the Observer when stack install command exits with code 0.

{
  id: 'build:complete'
}
(async () => {
  await downloadPurescript().filter(({id}) => id.endsWith(':complete')).forEach(({id}) => {
    console.log(`✓ ${id.replace(':complete', '')}`);
  });

  console.log('\nCompleted.');
})();
✓ download
✓ setup
✓ build

Completed.

Errors

Each error passed to the Observer have id property that indicates which step the error occurred at.

// When your machine have no network connection
buildPureScript().subscribe({
  error(err) {
    err.message; //=> 'getaddrinfo ENOTFOUND github.com github.com:443'
    err.id; //=> 'download'
  }
});

// When the `stack` command is not installed
buildPureScript().subscribe({
  error(err) {
    err.message; //=> '`stack` command is not found in your PATH ...'
    err.id; //=> 'setup'
  }
});

Options

Options are directly passed to the underlying donwload-purescript-source and spawn-stack. Also you can use the following:

args

Type: Array<string>

Additional command-line arguments passed to stack setup and stack install. Note:

  • --local-bin-path is automatically set to the first argument of buildPurescript.
  • Build-only flags, for example --fast and --pedantic, won't be passed to stack setup.

License

ISC License © 2017 - 2019 Shinnosuke Watanabe