Skip to content

Instantly share code, notes, and snippets.

@joliss
joliss / .bashrc
Last active August 29, 2015 14:26
glog() {
# requires git 1.8.3 for %C(auto) syntax
git log --graph --date=short --pretty="%Cblue%ad%Creset %C(auto)%h %Cblue%an%Creset%C(auto) %s __REFS:%d" "$@" \
| perl -pe 's/__REFS:[^(]*\(([^)]+)\).*/$refs=$1; $refs=~s{, }{ }g; $refs=~s{tag: }{}g; $refs/e' \
| less;
}
gl() {
glog "$@" | head -n 10;
}
diff --git a/index.js b/index.js
index 2ec4b85..d010a51 100644
--- a/index.js
+++ b/index.js
@@ -59,9 +59,9 @@ Babel.prototype = Object.create(Filter.prototype);
Babel.prototype.constructor = Babel;
Babel.prototype.targetExtension = ['js'];
-Babel.prototype.rebuild = function() {
+Babel.prototype.build = function() {
(function() {
'use strict'
function add(a, b) { return a + b }
var x = [1, 2]
console.time('apply')
for (let i = 0; i < 100000; i++) {
if (add.apply(null, x) === 4) throw 'dummy'
var Filter = require('./index')
CoffeeScriptFilter.prototype = Object.create(Filter.prototype)
CoffeeScriptFilter.prototype.constructor = CoffeeScriptFilter
function CoffeeScriptFilter () {
}
CoffeeScriptFilter.prototype.extensions = ['coffee', 'litcoffee', 'coffee.md']
CoffeeScriptFilter.prototype.targetExtension = 'js'
diff --git a/Brocfile.js b/Brocfile.js
index b938f55..17da220 100644
--- a/Brocfile.js
+++ b/Brocfile.js
@@ -10,6 +10,7 @@ var removeFile = require('broccoli-file-remover');
var path = require('path');
var jsStringEscape = require('js-string-escape');
var eslint = require('broccoli-lint-eslint');
+var mv = require('broccoli-stew').mv;
// Just a sketch - this API isn't implemented (yet)
// Common base class shared by all plugins
var makePlugin = require('broccoli-plugin')
var mergeTrees = makePlugin({
init: function(inputTrees, options) {
// You can define this function with any parameters you like; inputTrees
// and options are merely conventional. All arguments will be passed
// through from the plugin constructor.
module.exports = function(builder) {
var mergeTrees = require('broccoli-merge-trees')(builder)
return mergeTrees(['app', 'vendor'])
}
var makeTree = require('broccoli-plugin')
module.exports = mergeTrees
function mergeTrees(inputTrees, options) {
return makeTree({
inputTrees: inputTrees,
needsCache: true,
description: 'mergeTrees',
rebuild: function (inputPaths, outputPath, cachePath) {
// ...
@joliss
joliss / gist:d93b6ca378521e808edd
Last active August 29, 2015 14:17
Broccoli error objects

Reporting errors from Broccoli plugins

Background: We currently have a bunch of ad-hoc properties, but we'd like to make this more structured, so that we have a documented error API that we can evolve if necessary.

New proposal:

  • err.message: standard JS Error.prototype.message doubles as compiler error message
  • err.broccoliInfo:
    • .file: absolute path of input file
  • .firstLine, .firstColumn: one-indexed position of error