tyke

Tycode CoffeeScript build utility

npm install tyke
4 downloads in the last week
10 downloads in the last month

Instant CoffeeScript build utility. No Cakefiles required!

Install via npm

$ npm -g install tyke

Build any package in working directory

$ tyke build

Clean any package in working directory

$ tyke clean

Yes, it builds itself

So you can upgrade by doing:

$ git clone git://github.com/tycode/tyke.git
$ cd tyke
$ tyke build

and then copying/symlinking lib/main.js wherever you need it.

Prerequisites

If you want to use Tyke, you'll need to stick to a simple directory structure:

  • /package.json - must be a valid JSON file and include a valid version number
  • /src - your .coffee files
  • /lib - generated .js files go here, don't put anything here yourself or it'll be deleted
  • /bin - symlinks to executable .js files, again, don't put anything here yourself

To make a .js file executable and appear in /bin, use chmod to set the execute bit on the corresponding .coffee file.

Including more .js files

Put something like this on a line by itself (and not the first line of the file):

#~=(tyke include /path/to/package/lib/file.js)=~#

the path must be absolute and should point to a .js file in a lib/ directory. Maybe in future, relative paths will work.

Building lots of packages at once

Just put all your packages in another parent directory, and put the following in a package.json file in that parent directory:

{
  "x_tyke_mp": true
}

Then run tyke build or tyke clean from that parent directory as required. You can even nest them!

Generating files by running arbitrary commands

Put something like this in your package.json:

"x_tyke": {
  "tasks": [{
    "postbuild": {
      "target": "lib/hello.txt",
      "generator": "echo Hello, World! > %target%"
    }
  }, {
    "build": {
      "tasks": ["build", "postbuild"]
    }
  }, {
    "postbuild": false
  }]
},

This makes sure that whenever you run tyke build, it creates lib/hello.txt by running the specified command.

In more detail, it works by first creating a task called "postbuild" which actually does that, then recreates the task "build" to do the original build followed by postbuild, then deletes the postbuild task so you can't just run it with "tyke postbuild".

You can actually create any tasks you like this way, run them before instead of after, and so on.

Dependencies

Tyke will pay attention to the dependencies: key in your package.json and make sure they get built first, if they're in the same directory. This won't work with nested mp directories yet, though.

It'll also ensure that if you include a .js file from the same package, the file to be included gets compiled before the file that includes it.

It'll even do the clean operation in the reverse order! Even though this isn't yet really necessary...

License

3-clause BSD.

npm loves you