Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove coffeescript.

  • Loading branch information...
commit 3c91fc0cf13422c1c41255eafb4365d527b051b8 1 parent 1caf9a6
@paulmillr paulmillr authored
View
64 index.js
@@ -0,0 +1,64 @@
+var coffeescript = require('coffee-script');
+
+var isLiterate = function(path) {
+ return /\.(litcoffee|coffee\.md)$/.test(path);
+};
+
+var normalizeChecker = function(item) {
+ switch (toString.call(item)) {
+ case '[object RegExp]':
+ return function(string) {
+ return item.test(string);
+ };
+ case '[object Function]':
+ return item;
+ default:
+ return function() {
+ return false;
+ };
+ }
+};
+
+function CoffeeScriptCompiler(config) {
+ if (config == null) config = {};
+ var plugin = config.plugins && config.plugins.coffeescript;
+ var conv = config.conventions && config.conventions.vendor;
+ this.bare = plugin && plugin.bare;
+ this.sourceMaps = !!config.sourceMaps;
+ this.isVendor = normalizeChecker(conv);
+}
+
+CoffeeScriptCompiler.prototype.brunchPlugin = true;
+CoffeeScriptCompiler.prototype.type = 'javascript';
+CoffeeScriptCompiler.prototype.extension = 'coffee';
+CoffeeScriptCompiler.prototype.pattern = /\.(coffee(\.md)?|litcoffee)$/;
+
+CoffeeScriptCompiler.prototype.compile = function(data, path, callback) {
+ var options = {
+ bare: this.bare == null ? !this.isVendor(path) : this.bare,
+ sourceMap: this.sourceMaps,
+ sourceFiles: [path],
+ literate: isLiterate(path)
+ };
+ var compiled;
+ try {
+ compiled = coffeescript.compile(data, options);
+ } catch (err) {
+ var loc = err.location, error;
+ if (loc) {
+ error = loc.first_line + ":" + loc.first_column + " " + (err.toString());
+ } else {
+ error = err.toString();
+ }
+ return callback(error);
+ }
+ var result = (options.sourceMap && typeof compiled === 'object') ? {
+ data: compiled.js,
+ map: compiled.v3SourceMap
+ } : {
+ data: compiled
+ };
+ return callback(null, result);
+};
+
+module.exports = CoffeeScriptCompiler;
View
73 lib/index.js
@@ -1,73 +0,0 @@
-// Generated by CoffeeScript 1.6.3
-var CoffeeScriptCompiler, coffeescript, isLiterate, normalizeChecker;
-
-coffeescript = require('coffee-script');
-
-isLiterate = function(path) {
- return /\.(litcoffee|coffee\.md)$/.test(path);
-};
-
-normalizeChecker = function(item) {
- switch (toString.call(item)) {
- case '[object RegExp]':
- return function(string) {
- return item.test(string);
- };
- case '[object Function]':
- return item;
- default:
- return function() {
- return false;
- };
- }
-};
-
-module.exports = CoffeeScriptCompiler = (function() {
- CoffeeScriptCompiler.prototype.brunchPlugin = true;
-
- CoffeeScriptCompiler.prototype.type = 'javascript';
-
- CoffeeScriptCompiler.prototype.extension = 'coffee';
-
- CoffeeScriptCompiler.prototype.pattern = /\.(coffee|coffee\.md|litcoffee)$/;
-
- function CoffeeScriptCompiler(config) {
- var _ref, _ref1;
- this.config = config;
- this.isVendor = normalizeChecker((_ref = this.config) != null ? (_ref1 = _ref.conventions) != null ? _ref1.vendor : void 0 : void 0);
- }
-
- CoffeeScriptCompiler.prototype.compile = function(data, path, callback) {
- var bare, compiled, err, error, options, result, _ref, _ref1, _ref2, _ref3;
- bare = (_ref = this.config) != null ? (_ref1 = _ref.plugins) != null ? (_ref2 = _ref1.coffeescript) != null ? _ref2.bare : void 0 : void 0 : void 0;
- if (bare == null) {
- bare = !this.isVendor(path);
- }
- options = {
- bare: bare,
- sourceMap: Boolean((_ref3 = this.config) != null ? _ref3.sourceMaps : void 0),
- sourceFiles: [path],
- literate: isLiterate(path)
- };
- try {
- return compiled = coffeescript.compile(data, options);
- } catch (_error) {
- err = _error;
- return error = err.location != null ? "" + err.location.first_line + ":" + err.location.first_column + " " + (err.toString()) : err.toString();
- } finally {
- if (error != null) {
- return callback(error);
- }
- result = compiled && options.sourceMap ? {
- data: compiled.js,
- map: compiled.v3SourceMap
- } : {
- data: compiled
- };
- callback(error, result);
- }
- };
-
- return CoffeeScriptCompiler;
-
-})();
View
2  package.json
@@ -8,9 +8,7 @@
"type": "git",
"url": "git@github.com:brunch/coffee-script-brunch.git"
},
- "main": "./lib/index",
"scripts": {
- "prepublish": "rm -rf lib && coffee --bare --output lib/ src/",
"test": "node_modules/.bin/mocha --require test/common.js"
},
"dependencies": {
View
48 src/index.coffee
@@ -1,48 +0,0 @@
-coffeescript = require 'coffee-script'
-
-isLiterate = (path) ->
- /\.(litcoffee|coffee\.md)$/.test(path)
-
-normalizeChecker = (item) ->
- switch toString.call(item)
- when '[object RegExp]'
- (string) -> item.test string
- when '[object Function]'
- item
- else
- -> false
-
-module.exports = class CoffeeScriptCompiler
- brunchPlugin: yes
- type: 'javascript'
- extension: 'coffee'
- pattern: /\.(coffee|coffee\.md|litcoffee)$/
-
- constructor: (@config) ->
- @isVendor = normalizeChecker @config?.conventions?.vendor
-
- compile: (data, path, callback) ->
- bare = @config?.plugins?.coffeescript?.bare
- # Use this vendor test only if bare isn't explicitly set
- bare ?= not @isVendor path
- options =
- bare: bare
- sourceMap: Boolean @config?.sourceMaps
- sourceFiles: [path]
- literate: isLiterate path
-
- try
- compiled = coffeescript.compile data, options
- catch err
- error = if err.location?
- "#{err.location.first_line}:#{err.location.first_column} #{err.toString()}"
- else
- err.toString()
- finally
- return callback error if error?
- result = if compiled and options.sourceMap
- data: compiled.js,
- map: compiled.v3SourceMap
- else
- data: compiled
- callback error, result
View
2  test/common.js
@@ -1,2 +1,2 @@
global.expect = require('chai').expect;
-global.Plugin = require('../lib');
+global.Plugin = require('../');
Please sign in to comment.
Something went wrong with that request. Please try again.