Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Windows separator fix #41

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/stitch.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/stitch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ try
module._compile content, filename
catch err

sep = if process.platform == 'win32' then '\\' else '/'


exports.Package = class Package
constructor: (config) ->
@identifier = config.identifier ? 'require'
@paths = config.paths ? ['lib']
@paths = config.paths.map(normalize) ? ['lib']
@dependencies = config.dependencies ? []
@compilers = _.extend {}, compilers, config.compilers

Expand Down Expand Up @@ -61,6 +63,7 @@ exports.Package = class Package
(function(/*! Stitch !*/) {
if (!this.#{@identifier}) {
var modules = {}, cache = {}, require = function(name, root) {
name = name.replace(/\\\\/g, '/');
var path = expand(root, name), module = cache[path], fn;
if (module) {
return module.exports;
Expand Down Expand Up @@ -155,7 +158,7 @@ exports.Package = class Package
if err then callback err
else
extension = extname relativePath
key = relativePath.slice(0, -extension.length)
key = relativePath.slice(0, -extension.length).replace(/\\/g, '/')
sources[key] =
filename: relativePath
source: source
Expand All @@ -171,7 +174,7 @@ exports.Package = class Package
return callback err if err

for expandedPath in expandedPaths
base = expandedPath + "/"
base = expandedPath + sep
if sourcePath.indexOf(base) is 0
return callback null, sourcePath.slice base.length
callback new Error "#{path} isn't in the require path"
Expand Down