handmade
v0.2.1
Published
DIY build systems, tooling, and more.
Downloads
16
Readme
handmade
DIY build systems, tooling, and more.
- Small. The API is just 2 methods.
- Simple. A task is just a function that returns a Promise.
- Familiar. Easily write your own tasks using node and the ecosystem.
- Accessible. No complex plugin architecture or file handling.
- Fluid. Functions to the core. Functional in nature.
Getting Started
Install
# via npm
$ npm i handmade --save
# via yarn
$ yarn add handmade
Tasks
A task is a function that manipulates the build object.
handmade is a waterfall under the hood - a build runs all tasks in series, passing the same build object to each one.
See the example code below (thoroughly commented):
- Empty Task - A task that does nothing.
- Curried Task - A task that accepts options via currying.
First Build
Give this example a look. If you want to work with the filesystem, it's this simple:
// import handmade
const handmade = require('handmade')
// import fs read/write tasks
const {
read,
write
} = require('handmade-fs')
// define a custom task that has access to file data
const customTask = contents => new Promise((resolve, reject) => {
// destructure file data from contents
let { files } = contents.core
// do work here, sync or async, using the file data
// files is an object of file paths -> file contents
console.log(files)
// when done, resolve and pass along the contents object
resolve(contents)
})
// kick off a new build, passing a path to the root of your project
handmade(__dirname)
// point it to your source files
.task(read('./input'))
// add your custom task
.task(customTask)
// point it to where the output should go
.task(write('./output'))
// kick off the build
.build()
// do more with the result of the build, if you want to
.then(result => {
})
// when shit blows up
.catch(error => {
})
See Also
- handmade-fs - File system tasks for handmade.
License
MIT. © 2017 Michael Cavalea