Skip to content

Commit 29530ee

Browse files
committed
Windows support
1 parent ace2383 commit 29530ee

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

lib/parser.js

100644100755
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var create = Object.create
1111
, indent = require('es5-ext/lib/String/get-indent')()
1212
, deferred = require('deferred')
1313
, getRequire = require('next/lib/get-require')
14+
, separator = require('next/lib/path/separator')
1415
, findRoot = deferred.promisify(require('next/lib/find-package-root'))
1516
, fileExists = deferred.promisify(require('next/lib/fs/file-exists'))
1617
, dirExists = deferred.promisify(require('next/lib/fs/dir-exists'))
@@ -66,14 +67,15 @@ parser = {
6667
return findRoot(input)
6768
(function (root) {
6869
var name, dirs;
69-
name = root ? peek.call(root.split('/')) : '/';
70+
name = root ? peek.call(root.split(separator)) : separator;
7071
if (!this.modules[name]) {
71-
this.packages[name] = root || '/';
72+
this.packages[name] = root || separator;
7273
this.modules[name] = {};
7374
}
7475
scope = this.modules[name];
75-
path = name + '/' + (dirs = trimCommon.call(input, root || '').slice(1));
76-
dirs = dirs.split('/');
76+
path = name + separator +
77+
(dirs = trimCommon.call(input, root || '').slice(1));
78+
dirs = dirs.split(separator);
7779
name = dirs.pop();
7880
dirs.forEach(function (dir) {
7981
tree.push(scope);
@@ -82,7 +84,7 @@ parser = {
8284
return this.readFile(input, name, scope, tree);
8385
}.bind(this))
8486
(function () {
85-
return path.slice(0, -3);
87+
return path.slice(0, -3).replace(/\\/g, '/');
8688
})
8789
},
8890
readFile: function (filename, name, scope, tree) {
@@ -191,7 +193,7 @@ parser = {
191193
this.modules[name] = {};
192194
if (main) {
193195
this.modules[name][':mainpath:']
194-
= trimCommon.call(main, root).slice(1, -3);
196+
= trimCommon.call(main, root).slice(1, -3).replace('\\', '/');
195197
}
196198
return this.modules[name];
197199
}.bind(this));

lib/webmake.js

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var isArray = Array.isArray
44
, stringify = JSON.stringify
55
, fs = require('fs')
6-
, normalize = require('path').normalize
6+
, normalize = require('next/lib/path/normalize')
77
, aritize = require('es5-ext/lib/Function/prototype/aritize')
88
, invoke = require('es5-ext/lib/Function/invoke')
99
, isFunction = require('es5-ext/lib/Function/is-function')

test/parser.js

100644100755
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict';
22

3-
var pg = __dirname + '/__playground';
3+
var normalize = require('next/lib/path/normalize')
4+
, pg = __dirname + '/__playground';
45

56
module.exports = {
67
"": function (t, a, d) {
78
var input, parser;
8-
input = pg + '/lib/program.js'
9+
input = normalize(pg + '/lib/program.js');
910
parser = t();
1011
parser.readInput(input)
1112
(function (path) {

test/webmake.js

100644100755
File mode changed.

0 commit comments

Comments
 (0)