Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bump CoffeeScript dependency to 1.3.0 and rebuild

  • Loading branch information...
commit dc4c276f74c18ec9c4d24b196cc1b0e9ee2ab214 1 parent 1207ef8
Craig Davey authored
Showing with 39 additions and 20 deletions.
  1. +38 −19 lib/stitch.js
  2. +1 −1  package.json
View
57 lib/stitch.js
@@ -1,6 +1,7 @@
+// Generated by CoffeeScript 1.3.3
(function() {
- var CoffeeScript, Package, async, compilers, eco, extname, fs, join, normalize, _, _ref;
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+ var CoffeeScript, Package, async, compilers, eco, extname, fs, join, normalize, _, _ref,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
_ = require('underscore');
@@ -52,13 +53,15 @@
function Package(config) {
this.compileSources = __bind(this.compileSources, this);
+
this.compileDependencies = __bind(this.compileDependencies, this);
- var _ref2, _ref3, _ref4, _ref5;
- this.identifier = (_ref2 = config.identifier) != null ? _ref2 : 'require';
- this.paths = (_ref3 = config.paths) != null ? _ref3 : ['lib'];
- this.dependencies = (_ref4 = config.dependencies) != null ? _ref4 : [];
+
+ var _ref1, _ref2, _ref3, _ref4;
+ this.identifier = (_ref1 = config.identifier) != null ? _ref1 : 'require';
+ this.paths = (_ref2 = config.paths) != null ? _ref2 : ['lib'];
+ this.dependencies = (_ref3 = config.dependencies) != null ? _ref3 : [];
this.compilers = _.extend({}, compilers, config.compilers);
- this.cache = (_ref5 = config.cache) != null ? _ref5 : true;
+ this.cache = (_ref4 = config.cache) != null ? _ref4 : true;
this.mtimeCache = {};
this.compileCache = {};
}
@@ -87,12 +90,14 @@
Package.prototype.compileSources = function(callback) {
var _this = this;
return async.reduce(this.paths, {}, _.bind(this.gatherSourcesFromPath, this), function(err, sources) {
- var filename, index, name, result, source, _ref2;
- if (err) return callback(err);
+ var filename, index, name, result, source, _ref1;
+ if (err) {
+ return callback(err);
+ }
result = "(function(/*! Stitch !*/) {\n if (!this." + _this.identifier + ") {\n var modules = {}, cache = {}, require = function(name, root) {\n var path = expand(root, name), module = cache[path], fn;\n if (module) {\n return module.exports;\n } else if (fn = modules[path] || modules[path = expand(path, './index')]) {\n module = {id: path, exports: {}};\n try {\n cache[path] = module;\n fn(module.exports, function(name) {\n return require(name, dirname(path));\n }, module);\n return module.exports;\n } catch (err) {\n delete cache[path];\n throw err;\n }\n } else {\n throw 'module \\'' + name + '\\' not found';\n }\n }, expand = function(root, name) {\n var results = [], parts, part;\n if (/^\\.\\.?(\\/|$)/.test(name)) {\n parts = [root, name].join('/').split('/');\n } else {\n parts = name.split('/');\n }\n for (var i = 0, length = parts.length; i < length; i++) {\n part = parts[i];\n if (part == '..') {\n results.pop();\n } else if (part != '.' && part != '') {\n results.push(part);\n }\n }\n return results.join('/');\n }, dirname = function(path) {\n return path.split('/').slice(0, -1).join('/');\n };\n this." + _this.identifier + " = function(name) {\n return require(name, '');\n }\n this." + _this.identifier + ".define = function(bundle) {\n for (var key in bundle)\n modules[key] = bundle[key];\n };\n }\n return this." + _this.identifier + ".define;\n}).call(this)({";
index = 0;
for (name in sources) {
- _ref2 = sources[name], filename = _ref2.filename, source = _ref2.source;
+ _ref1 = sources[name], filename = _ref1.filename, source = _ref1.source;
result += index++ === 0 ? "" : ", ";
result += JSON.stringify(name);
result += ": function(exports, require, module) {" + source + "}";
@@ -127,10 +132,14 @@
Package.prototype.gatherSourcesFromPath = function(sources, sourcePath, callback) {
var _this = this;
return fs.stat(sourcePath, function(err, stat) {
- if (err) return callback(err);
+ if (err) {
+ return callback(err);
+ }
if (stat.isDirectory()) {
return _this.getFilesInTree(sourcePath, function(err, paths) {
- if (err) return callback(err);
+ if (err) {
+ return callback(err);
+ }
return async.reduce(paths, sources, _.bind(_this.gatherCompilableSource, _this), callback);
});
} else {
@@ -143,7 +152,9 @@
var _this = this;
if (this.compilers[extname(path).slice(1)]) {
return this.getRelativePath(path, function(err, relativePath) {
- if (err) return callback(err);
+ if (err) {
+ return callback(err);
+ }
return _this.compileFile(path, function(err, source) {
var extension, key;
if (err) {
@@ -167,10 +178,14 @@
Package.prototype.getRelativePath = function(path, callback) {
var _this = this;
return fs.realpath(path, function(err, sourcePath) {
- if (err) return callback(err);
+ if (err) {
+ return callback(err);
+ }
return async.map(_this.paths, fs.realpath, function(err, expandedPaths) {
var base, expandedPath, _i, _len;
- if (err) return callback(err);
+ if (err) {
+ return callback(err);
+ }
for (_i = 0, _len = expandedPaths.length; _i < _len; _i++) {
expandedPath = expandedPaths[_i];
base = expandedPath + "/";
@@ -220,14 +235,18 @@
Package.prototype.walkTree = function(directory, callback) {
var _this = this;
return fs.readdir(directory, function(err, files) {
- if (err) return callback(err);
+ if (err) {
+ return callback(err);
+ }
return async.forEach(files, function(file, next) {
var filename;
- if (file.match(/^\./)) return next();
+ if (file.match(/^\./)) {
+ return next();
+ }
filename = join(directory, file);
return fs.stat(filename, function(err, stats) {
- var _ref2;
- _this.mtimeCache[filename] = stats != null ? (_ref2 = stats.mtime) != null ? _ref2.toString() : void 0 : void 0;
+ var _ref1;
+ _this.mtimeCache[filename] = stats != null ? (_ref1 = stats.mtime) != null ? _ref1.toString() : void 0 : void 0;
if (!err && stats.isDirectory()) {
return _this.walkTree(filename, function(err, filename) {
if (filename) {
View
2  package.json
@@ -19,7 +19,7 @@
, "underscore": ">=1.1.3"
}
, "devDependencies" :
- { "coffee-script" : ">= 1.2.0"
+ { "coffee-script" : ">= 1.3.0"
, "nodeunit" : ">= 0.6.4"
, "eco": ">= 1.1.0-rc-3"
}
Please sign in to comment.
Something went wrong with that request. Please try again.