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

genome

v0.1.1

Published

Simple build system using ES6 generators and promises

Downloads

4

Readme

genome

Simple build system using ES6 classes, generators, and promises

Installation

genome requires io.js or node.js with harmony flags.

npm i -g genome
npm i -save-dev genome

Usage

Create a genomefile.js in your project's root directory.

var genome = require('genome');

genome.tasks = {
  // Tasks go here
};

// Run tasks passed in from command line
genome.run();

Create tasks

Tasks in genome are generator functions. Task names may include colons (:) and/or hyphens (-).

* sayhi() {
  console.log('Hello, world');
},

* 'say-something-else'() {
  console.log('Something else');
},

* 'say:goodbye'() {
  console.log('See ya later');
}

Run tasks

In your command line, run:

genome sayhi

genome commands may accept multiple tasks to run asyncronously:

genome sayhi say-something-else say:goodbye

Run a task from within another task using genome.spawn().

* speak() {
  genome.spawn('sayhi');

  // Or use genome's shorthand methods:
  genome.sayhi();
}

genome.spawn() accepts strings and arrays. Arrays of tasks will be run asyncronously.

* speak1() {
  genome.spawn(['sayhi', 'say-something-else', 'say:goodbye']);
},

// Is the same as:

* speak2() {
  genome.spawn('sayhi');
  genome.spawn('say-something-else');
  genome.spawn('say:goodbye');
}

If you need tasks to run in a certain order, add the yield statement before calling genome.spawn().

* speak2() {
  yield genome.spawn('sayhi');
  yield genome.spawn('say-something-else');
  genome.spawn('say:goodbye');
}

Read/write files

Genome adds read() and write() methods to strings to make reading and writing files as easy as:

return 'dist/html.index'.write(yield 'app/html.index'.read());

Genome also adds a .contents property as a read/write shorthand, so the same code can be written as:

'dist/html.index'.contents = yield 'app/html.index'.contents;

Not that read(), write() and the .contents getter all return promises, but the .contents setter does not return anything. So if you need the file to be written before something else happens, use write().

.write() accepts strings, promises, streams and arrays of file objects.

Processing files

Genome does not require plugins like gulp or grunt. Simply install standard node packages and use their build-in api.

* html() {
  // Process one file and output it
  var slm = require('slm');

  return 'dist/index.html'.write(slm.render(yield 'app/index.slm'.contents));
},

* scripts() {
  // Output stream to file
  var browserify = require('browserify');

  return 'dist/scripts/app.js'.write(browserify('app/scripts/app.js', { transform: 'babelify' }).bundle());
},

* styles() {
  // Output multiple files to directory with the String.prototype.use method
  var stylus = require('stylus');

  return 'dist/styles/'.write(yield 'app/styles/*.styl'.use(stylus.render, '.css'));
}

Watch files

Watch files for changes with String.prototype.onChange, passing in a function or a task name or array of task names.

* watch() {
  'app/**/*.slm'.onChange('html');
  'app/scripts/**/*.js'.onChange('scripts');
  'app/styles/**/*.styl'.onChange('styles');
  'dist/**/*'.onChange(browserSync.reload);
}

Project Goals

  • Never require speciallized plugins like Gulp and Grunt
  • Keep code as simple and natural as possible