Socket
Socket
Sign inDemoInstall

frosting

Package Overview
Dependencies
9
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    frosting

Task helpers for Cakefiles


Version published
Weekly downloads
17
Maintainers
1
Install size
1.76 MB
Created
Weekly downloads
 

Readme

Source

Frosting

Task helpers for Cakefiles

About

I've always been a little frustrated with the node filesystem API, especially when trying to get a build process in place for a javascript project. Frosting is really not much more than an abstraction layer over the filesystem module that helps keep Cakefiles readable.

Usage

To skip right to some code, here's an example Cakefile with build tasks for a client-side javascript library:

{each} = require 'frosting'

task 'compile:dev', 'Compile development distro files', ->
  each './lib/*.coffee', ( f ) -> f.compile -> f.write "./dist/dev/#{f.basename( )}.js"

task 'compile:min', 'Compile minified distro files', ->
  each './lib/*.coffee', ( f ) -> f.compile -> f.minify -> f.write "./dist/min/#{f.basename( )}.js"

task 'compile', 'Compile all distro files', ->
  invoke 'compile:dev'
  invoke 'compile:min'

Frosting is definitely an opinionated set of build tools. It assumes that source files are being written in coffeescript and minification will be done via uglify-js.

Frosting provides a couple of convenience methods that yield a File class. This class has the necessary API for reading, writing, mutating, inspecting, compiling and minifying source files.

each

each can be used to iterate over a set of source files. It accepts a callback which will be passed a File instance for each file, and you can build as you wish from there. It can be given a glob pattern or an explicit array of files.

each './lib/*.coffee', ( f ) -> # `f` is an instance of File

# or

each [
	'./lib/foo.coffee',
	'./lib/bar.coffee',
	'./lib/baz.coffee'
], ( f ) -> # `f` is an instance of File

concat

concat is similar to each, except it simply concatenates all of the source files into one coffeescript file and yields a File instance with the combined sources already in the buffer. If given an array of filenames, they will be read and concat'd in order.

concat './lib/*.coffee', ( f ) -> # `f` is an instance of File, will only get called once

# or

concat [
	'./lib/foo.coffee',
	'./lib/bar.coffee',
	'./lib/baz.coffee'
], ( f ) -> # `f` is an instance of File, will only get called once

TODO describe the File API

FAQs

Last updated on 25 Jun 2012

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc