From 9250477098190eac068c8cb4a55d0d5348146edd Mon Sep 17 00:00:00 2001 From: Thomas Stephens Date: Thu, 23 Feb 2012 19:02:23 -0600 Subject: [PATCH 1/3] Allow serving files from Windows while still using '/' in require() calls --- lib/stitch.js | 4 ++-- src/stitch.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/stitch.js b/lib/stitch.js index 967fb2b..0fd6db6 100644 --- a/lib/stitch.js +++ b/lib/stitch.js @@ -1,6 +1,6 @@ (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'); diff --git a/src/stitch.coffee b/src/stitch.coffee index cecca07..eb8d77f 100644 --- a/src/stitch.coffee +++ b/src/stitch.coffee @@ -171,9 +171,9 @@ exports.Package = class Package return callback err if err for expandedPath in expandedPaths - base = expandedPath + "/" + base = normalize expandedPath + "/" if sourcePath.indexOf(base) is 0 - return callback null, sourcePath.slice base.length + return callback null, sourcePath.slice(base.length).replace(/\\/g, '/') callback new Error "#{path} isn't in the require path" compileFile: (path, callback) -> From ee995e5ea168ff1adece0eb32dbb0ce73255cac1 Mon Sep 17 00:00:00 2001 From: Thomas Stephens Date: Thu, 23 Feb 2012 20:03:51 -0600 Subject: [PATCH 2/3] Compile Windows support to JS --- lib/stitch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stitch.js b/lib/stitch.js index 0fd6db6..015c52e 100644 --- a/lib/stitch.js +++ b/lib/stitch.js @@ -173,9 +173,9 @@ if (err) return callback(err); for (_i = 0, _len = expandedPaths.length; _i < _len; _i++) { expandedPath = expandedPaths[_i]; - base = expandedPath + "/"; + base = normalize(expandedPath + "/"); if (sourcePath.indexOf(base) === 0) { - return callback(null, sourcePath.slice(base.length)); + return callback(null, sourcePath.slice(base.length).replace(/\\/g, '/')); } } return callback(new Error("" + path + " isn't in the require path")); From 66ce046fe052709e55576f4397608df4cc1eab57 Mon Sep 17 00:00:00 2001 From: Thomas Stephens Date: Thu, 23 Feb 2012 20:04:21 -0600 Subject: [PATCH 3/3] Skip the symlink test on Windows --- test/test_stitch.coffee | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/test_stitch.coffee b/test/test_stitch.coffee index 112973e..ef20bef 100644 --- a/test/test_stitch.coffee +++ b/test/test_stitch.coffee @@ -299,12 +299,17 @@ module.exports = 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") + if process.platform == 'win32' + test.expect 1 + test.ok true, "Windows doesn't have symlinks" test.done() + else + 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) ->