Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buddy

Package Overview
Dependencies
Maintainers
1
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buddy

A tooling framework for the compilation of higher order js/css languages (coffeescript/stylus/less).

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Buddy

Buddy is primarily a tooling framework for the compilation of higher order js/css languages (coffeescript/stylus/less). Additionally, by enabling Node.js-style module wrapping and syntax, it promotes better js code organization, and provides automatic concatenation of code for more efficient delivery to the browser.

Installation

Use the -g global flag to make the buddy command available system-wide:

$ npm -g install buddy

Usage

$ cd path/to/my/project
# compile all source files
$ buddy compile
# watch for source changes and compile
$ buddy watch
# compile and minify for production
$ buddy deploy
# view usage, examples, and options
$ buddy --help

Configuration

The only requirement for adding Buddy support to a project is the presence of a buddy.json file:

{
  "js": {
    "sources": ["a/coffeescript/folder", "a/js/folder"],
    "targets": [
      {
        "in": "a/coffeescript/or/js/file",
        "out": "a/js/file/or/folder"
      },
      {
        "in": "a/coffeescript/folder",
        "out": "a/folder"
      }
    ]
  },
  "css": {
    "sources": ["a/stylus/folder", "a/less/folder"],
    "targets": [
      {
        "in": "a/stylus/or/less/file",
        "out": "a/css/file/or/folder"
      },
      {
        "in": "a/stylus/or/less/folder",
        "out": "a/folder"
      }
    ]
  }
}

For each build type (js/css), you begin by specifying source paths from which your build targets are referenced. Each build target should specify an input and corresponding output file or folder. Targets are run in sequence enabling you to chain builds together. As an example, you could compile a library, then reference some library files in your project:

"js": {
  "sources": ["lib/src/coffee", "lib/js", "src"],
  "targets": [
    {
      "in": "lib/src/coffee",  <--a folder of coffee-script files (including nested folders)
      "out": "lib/js"          <--a folder of compiled js files
    },
    {
      "in": "src/main.js",  <--the application entry point referencing library dependencies
      "out": "js/main.js"   <--a concatenation of referenced dependencies
    }
  ]
}

Modules

Buddy wraps each coffee-script/js file in a module declaration based on the file location. Dependencies (and concatenation order) are determined by the use of require statements:

var lib = require('./my/lib'); // in current package
var SomeClass = require('../some_class'); // in parent package

lib.doSomething();
var something = new SomeClass();

Specifying a module's public behaviour is achieved by decorating an exports object:

var myModuleVar = 'my module';

exports.myModuleMethod = function() { 
  return myModuleVar;
};

or overwriting the exports object completely:

function MyModule() {
  this.myVar = 'my instance var';
};

MyModule.prototype.myMethod = function() {
  return this.myVar;
};

module.exports = MyModule;

Each module is provided with a module, exports, and require reference.

When require-ing a module, keep in mind that the module id is resolved based on the following rules:

  • packages begin at the root folder specified in buddy.json > js > sources:
'Users/alex/project/src/package/main.js' > 'package/main'
  • uppercase filenames are converted to lowercase module ids:
'my/package/Class.js' > 'my/package/class'
  • camelcase filenames are converted to lowercase/underscore module ids:
'my/package/ClassCamelCase.js' > 'my/package/class_camel_case'

See node.js modules for more info on modules.

License

(The MIT License)

Copyright (c) 2011 Pope-Industries <alex@pope-industries.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 21 Nov 2011

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc