Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get rid of stitch

  • Loading branch information...
commit 237e5beb394cf51f53df9c97b9a8c4503a69b501 1 parent 246a450
@andreyvit andreyvit authored
Showing with 0 additions and 968 deletions.
  1. +0 −1  node_modules/stitch/.gitignore
  2. +0 −24 node_modules/stitch/Cakefile
  3. +0 −21 node_modules/stitch/LICENSE
  4. +0 −36 node_modules/stitch/README.md
  5. +0 −255 node_modules/stitch/lib/stitch.js
  6. +0 −26 node_modules/stitch/package.json
  7. +0 −240 node_modules/stitch/src/stitch.coffee
  8. +0 −4 node_modules/stitch/test/fixtures/additional/foo/bar.js
  9. +0 −1  node_modules/stitch/test/fixtures/additional/hello.js
  10. +0 −1  node_modules/stitch/test/fixtures/alternate/hello.alert
  11. +0 −3  node_modules/stitch/test/fixtures/alternate/nonsense.coffee
  12. 0  node_modules/stitch/test/fixtures/default/.dotfile.coffee
  13. +0 −4 node_modules/stitch/test/fixtures/default/circular/a.js
  14. +0 −4 node_modules/stitch/test/fixtures/default/circular/b.js
  15. +0 −2  node_modules/stitch/test/fixtures/default/circular/error.js
  16. +0 −3  node_modules/stitch/test/fixtures/default/circular/index.js
  17. +0 −3  node_modules/stitch/test/fixtures/default/custom_exports.js
  18. +0 −1  node_modules/stitch/test/fixtures/default/exported_property.coffee
  19. 0  node_modules/stitch/test/fixtures/default/foo.unknown
  20. +0 −1  node_modules/stitch/test/fixtures/default/foo/bar.coffee
  21. +0 −3  node_modules/stitch/test/fixtures/default/foo/bar/baz.js
  22. +0 −1  node_modules/stitch/test/fixtures/default/foo/baz.coffee
  23. +0 −2  node_modules/stitch/test/fixtures/default/foo/buz/index.coffee
  24. +0 −3  node_modules/stitch/test/fixtures/default/module.coffee
  25. +0 −2  node_modules/stitch/test/fixtures/default/relative/a.js
  26. +0 −1  node_modules/stitch/test/fixtures/default/relative/b.js
  27. +0 −4 node_modules/stitch/test/fixtures/default/relative/index.js
  28. +0 −1  node_modules/stitch/test/fixtures/dependencies/backbone.js
  29. +0 −1  node_modules/stitch/test/fixtures/dependencies/underscore.js
  30. +0 −1  node_modules/stitch/test/fixtures/dependencies/zepto.js
  31. +0 −4 node_modules/stitch/test/fixtures/eco/hello.html.eco
  32. +0 −1  node_modules/stitch/test/fixtures/link
  33. +0 −314 node_modules/stitch/test/test_stitch.coffee
View
1  node_modules/stitch/.gitignore
@@ -1 +0,0 @@
-node_modules/
View
24 node_modules/stitch/Cakefile
@@ -1,24 +0,0 @@
-require.paths.unshift "#{__dirname}/node_modules"
-
-require.paths.unshift __dirname + '/lib'
-
-{print} = require 'sys'
-{spawn} = require 'child_process'
-
-build = (callback) ->
- coffee = spawn 'coffee', ['-c', '-o', 'lib', 'src']
- coffee.stderr.on 'data', (data) ->
- process.stderr.write data.toString()
- coffee.stdout.on 'data', (data) ->
- print data.toString()
- coffee.on 'exit', (code) ->
- callback?() if code is 0
-
-task 'build', 'Build lib/ from src/', ->
- build()
-
-task 'test', 'Run tests', ->
- build ->
- process.chdir __dirname
- {reporters} = require 'nodeunit'
- reporters.default.run ['test']
View
21 node_modules/stitch/LICENSE
@@ -1,21 +0,0 @@
-Copyright (c) 2010 Joshua Peek
-Copyright (c) 2010 Sam Stephenson
-
-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.
View
36 node_modules/stitch/README.md
@@ -1,36 +0,0 @@
-<img src="https://github.com/downloads/sstephenson/stitch/logo.jpg"
-width=432 height=329>
-
-Develop and test your JavaScript applications as CommonJS modules in
-Node.js. Then __Stitch__ them together to run in the browser.
-
- npm install stitch
-
-Bundle code in lib/ and vendor/ and serve it with [Express](http://expressjs.com/):
-
- var stitch = require('stitch');
- var express = require('express');
-
- var package = stitch.createPackage({
- paths: [__dirname + '/lib', __dirname + '/vendor']
- });
-
- var app = express.createServer();
- app.get('/application.js', package.createServer());
- app.listen(3000);
-
-Or build it to a file:
-
- var stitch = require('stitch');
- var fs = require('fs');
-
- var package = stitch.createPackage({
- paths: [__dirname + '/lib', __dirname + '/vendor']
- });
-
- package.compile(function (err, source){
- fs.writeFile('package.js', source, function (err) {
- if (err) throw err;
- console.log('Compiled package.js');
- })
- })
View
255 node_modules/stitch/lib/stitch.js
@@ -1,255 +0,0 @@
-(function() {
- var CoffeeScript, Package, async, compilers, eco, extname, fs, join, normalize, _, _ref;
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
- _ = require('underscore');
- async = require('async');
- fs = require('fs');
- _ref = require('path'), extname = _ref.extname, join = _ref.join, normalize = _ref.normalize;
- exports.compilers = compilers = {
- js: function(module, filename) {
- var content;
- content = fs.readFileSync(filename, 'utf8');
- return module._compile(content, filename);
- }
- };
- try {
- CoffeeScript = require('coffee-script');
- compilers.coffee = function(module, filename) {
- var content;
- content = CoffeeScript.compile(fs.readFileSync(filename, 'utf8'));
- return module._compile(content, filename);
- };
- } catch (err) {
-
- }
- try {
- eco = require('eco');
- if (eco.precompile) {
- compilers.eco = function(module, filename) {
- var content;
- content = eco.precompile(fs.readFileSync(filename, 'utf8'));
- return module._compile("module.exports = " + content, filename);
- };
- } else {
- compilers.eco = function(module, filename) {
- var content;
- content = eco.compile(fs.readFileSync(filename, 'utf8'));
- return module._compile(content, filename);
- };
- }
- } catch (err) {
-
- }
- exports.Package = Package = (function() {
- 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 : [];
- this.compilers = _.extend({}, compilers, config.compilers);
- this.cache = (_ref5 = config.cache) != null ? _ref5 : true;
- this.mtimeCache = {};
- this.compileCache = {};
- }
- Package.prototype.compile = function(callback) {
- return async.parallel([this.compileDependencies, this.compileSources], function(err, parts) {
- if (err) {
- return callback(err);
- } else {
- return callback(null, parts.join("\n"));
- }
- });
- };
- Package.prototype.compileDependencies = function(callback) {
- return async.map(this.dependencies, fs.readFile, __bind(function(err, dependencySources) {
- if (err) {
- return callback(err);
- } else {
- return callback(null, dependencySources.join("\n"));
- }
- }, this));
- };
- Package.prototype.compileSources = function(callback) {
- return async.reduce(this.paths, {}, _.bind(this.gatherSourcesFromPath, this), __bind(function(err, sources) {
- var filename, index, name, result, source, _ref2;
- if (err) {
- return callback(err);
- }
- result = "(function(/*! Stitch !*/) {\n if (!this." + this.identifier + ") {\n var modules = {}, cache = {}, require = function(name, root) {\n var module = cache[name], path = expand(root, name), fn;\n if (module) {\n return module;\n } else if (fn = modules[path] || modules[path = expand(path, './index')]) {\n module = {id: name, exports: {}};\n try {\n cache[name] = module.exports;\n fn(module.exports, function(name) {\n return require(name, dirname(path));\n }, module);\n return cache[name] = module.exports;\n } catch (err) {\n delete cache[name];\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;
- result += index++ === 0 ? "" : ", ";
- result += JSON.stringify(name);
- result += ": function(exports, require, module) {" + source + "}";
- }
- result += "});\n";
- return callback(err, result);
- }, this));
- };
- Package.prototype.createServer = function() {
- return __bind(function(req, res, next) {
- return this.compile(function(err, source) {
- var message;
- if (err) {
- console.error("" + err.stack);
- message = "" + err.stack;
- res.writeHead(500, {
- 'Content-Type': 'text/javascript'
- });
- return res.end("throw " + (JSON.stringify(message)));
- } else {
- res.writeHead(200, {
- 'Content-Type': 'text/javascript'
- });
- return res.end(source);
- }
- });
- }, this);
- };
- Package.prototype.gatherSourcesFromPath = function(sources, sourcePath, callback) {
- return fs.stat(sourcePath, __bind(function(err, stat) {
- if (err) {
- return callback(err);
- }
- if (stat.isDirectory()) {
- return this.getFilesInTree(sourcePath, __bind(function(err, paths) {
- if (err) {
- return callback(err);
- }
- return async.reduce(paths, sources, _.bind(this.gatherCompilableSource, this), callback);
- }, this));
- } else {
- return this.gatherCompilableSource(sources, sourcePath, callback);
- }
- }, this));
- };
- Package.prototype.gatherCompilableSource = function(sources, path, callback) {
- if (this.compilers[extname(path).slice(1)]) {
- return this.getRelativePath(path, __bind(function(err, relativePath) {
- if (err) {
- return callback(err);
- }
- return this.compileFile(path, function(err, source) {
- var extension, key;
- if (err) {
- return callback(err);
- } else {
- extension = extname(relativePath);
- key = relativePath.slice(0, -extension.length);
- sources[key] = {
- filename: relativePath,
- source: source
- };
- return callback(err, sources);
- }
- });
- }, this));
- } else {
- return callback(null, sources);
- }
- };
- Package.prototype.getRelativePath = function(path, callback) {
- return fs.realpath(path, __bind(function(err, sourcePath) {
- 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);
- }
- for (_i = 0, _len = expandedPaths.length; _i < _len; _i++) {
- expandedPath = expandedPaths[_i];
- base = expandedPath + "/";
- if (sourcePath.indexOf(base) === 0) {
- return callback(null, sourcePath.slice(base.length));
- }
- }
- return callback(new Error("" + path + " isn't in the require path"));
- });
- }, this));
- };
- Package.prototype.compileFile = function(path, callback) {
- var compile, err, extension, mod, mtime, source;
- extension = extname(path).slice(1);
- if (this.cache && this.compileCache[path] && this.mtimeCache[path] === this.compileCache[path].mtime) {
- return callback(null, this.compileCache[path].source);
- } else if (compile = this.compilers[extension]) {
- source = null;
- mod = {
- _compile: function(content, filename) {
- return source = content;
- }
- };
- try {
- compile(mod, path);
- if (this.cache && (mtime = this.mtimeCache[path])) {
- this.compileCache[path] = {
- mtime: mtime,
- source: source
- };
- }
- return callback(null, source);
- } catch (err) {
- if (err instanceof Error) {
- err.message = "can't compile " + path + "\n" + err.message;
- } else {
- err = new Error("can't compile " + path + "\n" + err);
- }
- return callback(err);
- }
- } else {
- return callback(new Error("no compiler for '." + extension + "' files"));
- }
- };
- Package.prototype.walkTree = function(directory, callback) {
- return fs.readdir(directory, __bind(function(err, files) {
- if (err) {
- return callback(err);
- }
- return async.forEach(files, __bind(function(file, next) {
- var filename;
- if (file.match(/^\./)) {
- return next();
- }
- filename = join(directory, file);
- return fs.stat(filename, __bind(function(err, stats) {
- var _ref2;
- this.mtimeCache[filename] = stats != null ? (_ref2 = stats.mtime) != null ? _ref2.toString() : void 0 : void 0;
- if (!err && stats.isDirectory()) {
- return this.walkTree(filename, function(err, filename) {
- if (filename) {
- return callback(err, filename);
- } else {
- return next();
- }
- });
- } else {
- callback(err, filename);
- return next();
- }
- }, this));
- }, this), callback);
- }, this));
- };
- Package.prototype.getFilesInTree = function(directory, callback) {
- var files;
- files = [];
- return this.walkTree(directory, function(err, filename) {
- if (err) {
- return callback(err);
- } else if (filename) {
- return files.push(filename);
- } else {
- return callback(err, files.sort());
- }
- });
- };
- return Package;
- })();
- exports.createPackage = function(config) {
- return new Package(config);
- };
-}).call(this);
View
26 node_modules/stitch/package.json
@@ -1,26 +0,0 @@
-{ "name": "stitch"
-, "description": "Stitch your CommonJS modules together for the browser"
-, "contributors":
- [ "Josh Peek"
- , "Sam Stephenson"
- ]
-, "version": "0.3.2"
-, "licenses": [
- { "type": "MIT"
- , "url": "http://github.com/sstephenson/stitch/raw/master/LICENSE"
- }]
-, "main": "./lib/stitch"
-, "repository":
- { "type": "git"
- , "url": "http://github.com/sstephenson/stitch.git"
- }
-, "dependencies":
- { "async": ">=0.1.6"
- , "underscore": ">=1.1.3"
- }
-, "devDependencies" :
- { "coffee-script" : ">= 1.0.0"
- , "nodeunit" : ">= 0.5.0"
- , "eco": ">= 1.0.0"
- }
-}
View
240 node_modules/stitch/src/stitch.coffee
@@ -1,240 +0,0 @@
-_ = require 'underscore'
-async = require 'async'
-fs = require 'fs'
-
-{extname, join, normalize} = require 'path'
-
-exports.compilers = compilers =
- js: (module, filename) ->
- content = fs.readFileSync filename, 'utf8'
- module._compile content, filename
-
-try
- CoffeeScript = require 'coffee-script'
- compilers.coffee = (module, filename) ->
- content = CoffeeScript.compile fs.readFileSync filename, 'utf8'
- module._compile content, filename
-catch err
-
-try
- eco = require 'eco'
- if eco.precompile
- compilers.eco = (module, filename) ->
- content = eco.precompile fs.readFileSync filename, 'utf8'
- module._compile "module.exports = #{content}", filename
- else
- compilers.eco = (module, filename) ->
- content = eco.compile fs.readFileSync filename, 'utf8'
- module._compile content, filename
-catch err
-
-
-exports.Package = class Package
- constructor: (config) ->
- @identifier = config.identifier ? 'require'
- @paths = config.paths ? ['lib']
- @dependencies = config.dependencies ? []
- @compilers = _.extend {}, compilers, config.compilers
-
- @cache = config.cache ? true
- @mtimeCache = {}
- @compileCache = {}
-
- compile: (callback) ->
- async.parallel [
- @compileDependencies
- @compileSources
- ], (err, parts) ->
- if err then callback err
- else callback null, parts.join("\n")
-
- compileDependencies: (callback) =>
- async.map @dependencies, fs.readFile, (err, dependencySources) =>
- if err then callback err
- else callback null, dependencySources.join("\n")
-
- compileSources: (callback) =>
- async.reduce @paths, {}, _.bind(@gatherSourcesFromPath, @), (err, sources) =>
- return callback err if err
-
- result = """
- (function(/*! Stitch !*/) {
- if (!this.#{@identifier}) {
- var modules = {}, cache = {}, require = function(name, root) {
- var module = cache[name], path = expand(root, name), fn;
- if (module) {
- return module;
- } else if (fn = modules[path] || modules[path = expand(path, './index')]) {
- module = {id: name, exports: {}};
- try {
- cache[name] = module.exports;
- fn(module.exports, function(name) {
- return require(name, dirname(path));
- }, module);
- return cache[name] = module.exports;
- } catch (err) {
- delete cache[name];
- throw err;
- }
- } else {
- throw 'module \\'' + name + '\\' not found';
- }
- }, expand = function(root, name) {
- var results = [], parts, part;
- if (/^\\.\\.?(\\/|$)/.test(name)) {
- parts = [root, name].join('/').split('/');
- } else {
- parts = name.split('/');
- }
- for (var i = 0, length = parts.length; i < length; i++) {
- part = parts[i];
- if (part == '..') {
- results.pop();
- } else if (part != '.' && part != '') {
- results.push(part);
- }
- }
- return results.join('/');
- }, dirname = function(path) {
- return path.split('/').slice(0, -1).join('/');
- };
- this.#{@identifier} = function(name) {
- return require(name, '');
- }
- this.#{@identifier}.define = function(bundle) {
- for (var key in bundle)
- modules[key] = bundle[key];
- };
- }
- return this.#{@identifier}.define;
- }).call(this)({
- """
-
- index = 0
- for name, {filename, source} of sources
- result += if index++ is 0 then "" else ", "
- result += JSON.stringify name
- result += ": function(exports, require, module) {#{source}}"
-
- result += """
- });\n
- """
-
- callback err, result
-
- createServer: ->
- (req, res, next) =>
- @compile (err, source) ->
- if err
- console.error "#{err.stack}"
- message = "" + err.stack
- res.writeHead 500, 'Content-Type': 'text/javascript'
- res.end "throw #{JSON.stringify(message)}"
- else
- res.writeHead 200, 'Content-Type': 'text/javascript'
- res.end source
-
-
- gatherSourcesFromPath: (sources, sourcePath, callback) ->
- fs.stat sourcePath, (err, stat) =>
- return callback err if err
-
- if stat.isDirectory()
- @getFilesInTree sourcePath, (err, paths) =>
- return callback err if err
- async.reduce paths, sources, _.bind(@gatherCompilableSource, @), callback
- else
- @gatherCompilableSource sources, sourcePath, callback
-
- gatherCompilableSource: (sources, path, callback) ->
- if @compilers[extname(path).slice(1)]
- @getRelativePath path, (err, relativePath) =>
- return callback err if err
-
- @compileFile path, (err, source) ->
- if err then callback err
- else
- extension = extname relativePath
- key = relativePath.slice(0, -extension.length)
- sources[key] =
- filename: relativePath
- source: source
- callback err, sources
- else
- callback null, sources
-
- getRelativePath: (path, callback) ->
- fs.realpath path, (err, sourcePath) =>
- return callback err if err
-
- async.map @paths, fs.realpath, (err, expandedPaths) ->
- return callback err if err
-
- for expandedPath in expandedPaths
- base = expandedPath + "/"
- if sourcePath.indexOf(base) is 0
- return callback null, sourcePath.slice base.length
- callback new Error "#{path} isn't in the require path"
-
- compileFile: (path, callback) ->
- extension = extname(path).slice(1)
-
- if @cache and @compileCache[path] and @mtimeCache[path] is @compileCache[path].mtime
- callback null, @compileCache[path].source
- else if compile = @compilers[extension]
- source = null
- mod =
- _compile: (content, filename) ->
- source = content
-
- try
- compile mod, path
-
- if @cache and mtime = @mtimeCache[path]
- @compileCache[path] = {mtime, source}
-
- callback null, source
- catch err
- if err instanceof Error
- err.message = "can't compile #{path}\n#{err.message}"
- else
- err = new Error "can't compile #{path}\n#{err}"
- callback err
- else
- callback new Error "no compiler for '.#{extension}' files"
-
- walkTree: (directory, callback) ->
- fs.readdir directory, (err, files) =>
- return callback err if err
-
- async.forEach files, (file, next) =>
- return next() if file.match /^\./
- filename = join directory, file
-
- fs.stat filename, (err, stats) =>
- @mtimeCache[filename] = stats?.mtime?.toString()
-
- if !err and stats.isDirectory()
- @walkTree filename, (err, filename) ->
- if filename
- callback err, filename
- else
- next()
- else
- callback err, filename
- next()
- , callback
-
- getFilesInTree: (directory, callback) ->
- files = []
- @walkTree directory, (err, filename) ->
- if err
- callback err
- else if filename
- files.push filename
- else
- callback err, files.sort()
-
-
-exports.createPackage = (config) ->
- new Package config
View
4 node_modules/stitch/test/fixtures/additional/foo/bar.js
@@ -1,4 +0,0 @@
-(function() {
- var bar;
- bar = "baz";
-}).call(this);
View
1  node_modules/stitch/test/fixtures/additional/hello.js
@@ -1 +0,0 @@
-exports.hello = "hello";
View
1  node_modules/stitch/test/fixtures/alternate/hello.alert
@@ -1 +0,0 @@
-hello world
View
3  node_modules/stitch/test/fixtures/alternate/nonsense.coffee
@@ -1,3 +0,0 @@
-# This is some nonsense that should throw a parse error
-
-class for when if void
View
0  node_modules/stitch/test/fixtures/default/.dotfile.coffee
No changes.
View
4 node_modules/stitch/test/fixtures/default/circular/a.js
@@ -1,4 +0,0 @@
-exports.a = function() {
- return "a";
-};
-exports.b = require("./b").b;
View
4 node_modules/stitch/test/fixtures/default/circular/b.js
@@ -1,4 +0,0 @@
-var a = require("./a");
-exports.b = function() {
- return a.a();
-}
View
2  node_modules/stitch/test/fixtures/default/circular/error.js
@@ -1,2 +0,0 @@
-exports.a = require('./a');
-throw 'hello';
View
3  node_modules/stitch/test/fixtures/default/circular/index.js
@@ -1,3 +0,0 @@
-(function() {
- exports.buz = "BUZ";
-}).call(this);
View
3  node_modules/stitch/test/fixtures/default/custom_exports.js
@@ -1,3 +0,0 @@
-module.exports = function() {
- return "foo";
-}
View
1  node_modules/stitch/test/fixtures/default/exported_property.coffee
@@ -1 +0,0 @@
-exports.foo = "bar"
View
0  node_modules/stitch/test/fixtures/default/foo.unknown
No changes.
View
1  node_modules/stitch/test/fixtures/default/foo/bar.coffee
@@ -1 +0,0 @@
-bar = "baz"
View
3  node_modules/stitch/test/fixtures/default/foo/bar/baz.js
@@ -1,3 +0,0 @@
-(function() {
- exports.baz = "biz";
-}).call(this);
View
1  node_modules/stitch/test/fixtures/default/foo/baz.coffee
@@ -1 +0,0 @@
-exports.baz = "biz"
View
2  node_modules/stitch/test/fixtures/default/foo/buz/index.coffee
@@ -1,2 +0,0 @@
-
-exports.buz= "BUZ"
View
3  node_modules/stitch/test/fixtures/default/module.coffee
@@ -1,3 +0,0 @@
-exports.foo = require("exported_property").foo
-exports.bar = require("custom_exports")
-exports.baz = require("foo/bar/baz").baz
View
2  node_modules/stitch/test/fixtures/default/relative/a.js
@@ -1,2 +0,0 @@
-exports.a = "a";
-exports.b = require("./b");
View
1  node_modules/stitch/test/fixtures/default/relative/b.js
@@ -1 +0,0 @@
-module.exports = "b";
View
4 node_modules/stitch/test/fixtures/default/relative/index.js
@@ -1,4 +0,0 @@
-exports.a = require("./a");
-exports.custom = require("../custom_exports");
-exports.baz = require("../foo/bar/baz").baz;
-exports.buz = require("../foo/bar/../buz").buz;
View
1  node_modules/stitch/test/fixtures/dependencies/backbone.js
@@ -1 +0,0 @@
-// Backbone
View
1  node_modules/stitch/test/fixtures/dependencies/underscore.js
@@ -1 +0,0 @@
-// Underscore
View
1  node_modules/stitch/test/fixtures/dependencies/zepto.js
@@ -1 +0,0 @@
-// Zepto
View
4 node_modules/stitch/test/fixtures/eco/hello.html.eco
@@ -1,4 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-hello <%= @name %>!
View
1  node_modules/stitch/test/fixtures/link
View
314 node_modules/stitch/test/test_stitch.coffee
@@ -1,314 +0,0 @@
-sys = require "sys"
-fs = require "fs"
-stitch = require "stitch"
-
-fixtureRoot = __dirname + "/fixtures"
-fixtures = fixtureRoot + "/default"
-altFixtures = fixtureRoot + "/alternate"
-addlFixtures = fixtureRoot + "/additional"
-ecoFixtures = fixtureRoot + "/eco"
-linkFixtures = fixtureRoot + "/link"
-fixtureCount = 15
-
-defaultOptions =
- identifier: "testRequire"
- paths: [fixtures]
-defaultPackage = stitch.createPackage defaultOptions
-
-additionalOptions =
- identifier: "testRequire"
- paths: [addlFixtures]
-additionalPackage = stitch.createPackage additionalOptions
-
-alternateOptions =
- paths: [altFixtures]
-alternatePackage = stitch.createPackage alternateOptions
-
-ecoOptions =
- identifier: "testRequire"
- paths: [ecoFixtures]
-ecoPackage = stitch.createPackage ecoOptions
-
-dependencyOptions =
- identifier: "testRequire"
- paths: [fixtures]
- dependencies: [
- fixtureRoot + "/dependencies/zepto.js"
- fixtureRoot + "/dependencies/underscore.js"
- fixtureRoot + "/dependencies/backbone.js"
- ]
-dependencyPackage = stitch.createPackage dependencyOptions
-
-linkOptions =
- identifier: "testRequire"
- paths: [linkFixtures]
-linkPackage = stitch.createPackage linkOptions
-
-
-load = (source, callback) ->
- (-> eval source).call module = {}
- callback? (source) -> (-> eval source).call module
- module.testRequire
-
-rescue = (callback) ->
- rescued = false
- try
- callback()
- catch err
- rescued = true
- rescued
-
-
-module.exports =
- "walk tree": (test) ->
- test.expect fixtureCount
-
- defaultPackage.walkTree fixtures, (err, file) ->
- if file
- test.ok file
- else
- test.done()
-
- "get files in tree": (test) ->
- test.expect 2
-
- defaultPackage.getFilesInTree fixtures, (err, files) ->
- test.ok !err
- test.same fixtureCount, files.length
- test.done()
-
- "get files in tree that does not exist": (test) ->
- test.expect 1
-
- defaultPackage.getFilesInTree fixtures + "/missing", (err, files) ->
- test.ok err
- test.done()
-
- "get files in empty directory": (test) ->
- test.expect 1
-
- dirname = fixtures + "/empty"
- fs.mkdirSync dirname, 0755
- defaultPackage.getFilesInTree dirname, (err, files) ->
- test.ok !err
- fs.rmdirSync dirname
- test.done()
-
- "compile file": (test) ->
- test.expect 2
-
- defaultPackage.compileFile __filename, (err, source) ->
- test.ok !err
- test.ok source.match(/\(function\(\) \{/)
- test.done()
-
- "compile file does not exist": (test) ->
- test.expect 1
-
- defaultPackage.compileFile "nosuchthing.coffee", (err, source) ->
- test.ok err
- test.done()
-
- "compile file with syntax error": (test) ->
- test.expect 1
-
- alternatePackage.compileFile altFixtures + "/nonsense.coffee", (err, source) ->
- test.ok err.toString().match(/SyntaxError/)
- test.done()
-
- "compile file with custom compiler": (test) ->
- test.expect 1
-
- options = Object.create alternateOptions
- options.compilers =
- alert: (module, filename) ->
- source = require('fs').readFileSync filename, 'utf8'
- source = "alert(#{sys.inspect source});"
- module._compile source, filename
- package = stitch.createPackage options
-
- package.compileFile altFixtures + "/hello.alert", (err, source) ->
- test.same "alert('hello world\\n');", source
- test.done()
-
- "compile file with unknown extension": (test) ->
- test.expect 1
-
- alternatePackage.compileFile altFixtures + "/hello.alert", (err, source) ->
- test.ok err.toString().match(/no compiler/)
- test.done()
-
- "get relative path": (test) ->
- test.expect 2
-
- defaultPackage.getRelativePath fixtures + "/foo/bar.coffee", (err, path) ->
- test.ok !err
- test.same 'foo/bar.coffee', path
- test.done()
-
- "compile generates valid javascript": (test) ->
- test.expect 2
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- test.ok typeof testRequire is "function"
- test.done()
-
- "compile module with custom exports": (test) ->
- test.expect 3
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- result = testRequire("custom_exports")
- test.ok typeof result is "function"
- test.same "foo", result()
- test.done()
-
- "compile module with exported property": (test) ->
- test.expect 2
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- test.same "bar", testRequire("exported_property").foo
- test.done()
-
- "compile module with requires": (test) ->
- test.expect 4
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- module = testRequire("module")
- test.same "bar", module.foo
- test.same "foo", module.bar()
- test.same "biz", module.baz
- test.done()
-
- "runtime require only loads files once": (test) ->
- test.expect 3
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- module = testRequire("module")
- test.ok !module.x
- module.x = "foo"
- test.same "foo", testRequire("module").x
- test.done()
-
- "look for module index if necessary": (test) ->
- test.expect 2
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- buz = testRequire("foo/buz").buz
- test.same buz, "BUZ"
- test.done()
-
- "modules can be defined at runtime": (test) ->
- test.expect 3
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
-
- test.ok rescue -> testRequire("frob")
-
- testRequire.define
- "frob": (exports, require, module) ->
- exports.frob = require("foo/buz").buz
-
- test.same "BUZ", testRequire("frob").frob
- test.done()
-
- "multiple packages may share the same require namespace": (test) ->
- test.expect 5
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources, (load) ->
- additionalPackage.compile (err, sources) ->
- test.ok !err
- load sources
-
- test.same "hello", testRequire("hello").hello
- test.same "additional/foo/bar.js", testRequire("foo/bar").filename
- test.same "biz", testRequire("foo/bar/baz").baz;
- test.done()
-
- "relative require": (test) ->
- test.expect 6
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
-
- relative = testRequire("relative")
- test.same "a", relative.a.a
- test.same "b", relative.a.b
- test.same "foo", relative.custom()
- test.same "biz", relative.baz
- test.same "BUZ", relative.buz
- test.done()
-
- "circular require": (test) ->
- test.expect 4
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
-
- circular = testRequire("circular")
- test.same "a", circular.a.a()
- test.same "a", circular.b.b()
- test.same "a", circular.a.b()
- test.done()
-
- "errors at require time don't leave behind a partially loaded cache": (test) ->
- test.expect 3
-
- defaultPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
-
- test.ok rescue -> testRequire("circular/error")
- test.ok rescue -> testRequire("circular/error")
- test.done()
-
- "dependencies option concatenates files in order": (test) ->
- test.expect 5
- dependencyPackage.compile (err, sources) ->
- test.ok !err
- lines = sources.split("\n").slice(0, 5)
-
- test.same "// Zepto", lines[0]
- test.same "// Underscore", lines[2]
- test.same "// Backbone", lines[4]
-
- testRequire = load sources
- test.ok testRequire("foo/bar/baz")
- test.done()
-
- "paths may be symlinks": (test) ->
- test.expect 2
- linkPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
- test.ok testRequire("foo/bar/baz")
- test.done()
-
-if stitch.compilers.eco
- module.exports["eco compiler"] = (test) ->
- test.expect 2
- ecoPackage.compile (err, sources) ->
- test.ok !err
- testRequire = load sources
-
- html = testRequire("hello.html")(name: "Sam").trim()
- test.same "hello Sam!", html.split("\n").pop()
- test.done()
-
Please sign in to comment.
Something went wrong with that request. Please try again.