diff --git a/index.js b/index.js index 034b1eb..2089a03 100644 --- a/index.js +++ b/index.js @@ -5,8 +5,8 @@ var fs = require("fs") module.exports = function (options) { return through.obj(function (file, enc, cb) { - var baseArr = file.base.split(/\/|\\/) - baseArr.pop() + var pathArr = file.path.split(/\/|\\/) + pathArr.pop() var contents = file.contents.toString(enc).replace(/require\((["'])([\.\w\d\/]+)\1\)/g, function(req, quote, rawUrl) { var urlArr = rawUrl.split("/") var fileName = urlArr[urlArr.length-1] @@ -18,19 +18,19 @@ module.exports = function (options) { var url switch (urlArr[0]) { case ".." : - baseArr.pop() + pathArr.pop() for (var i = 1; i < urlArr.length; i++) { if (urlArr[i] == "..") { - baseArr.pop() + pathArr.pop() } else { - baseArr.push(urlArr[i]) + pathArr.push(urlArr[i]) } } - url = baseArr.join("/") + url = pathArr.join("/") break; case "." : urlArr.shift() - url = file.base + urlArr.join("/") + url = pathArr.join("/") + "/" + urlArr.join("/") break; default : new gutil.PluginError({ @@ -38,7 +38,6 @@ module.exports = function (options) { message: 'unsupported url' }); } - gutil.log(url) if (url) { var text = fs.readFileSync(url, "utf8") switch (suffix) { diff --git a/package.json b/package.json index e00c6c6..9a1fd5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-module-bundler", - "version": "0.1.1", + "version": "0.1.2", "description": "A gulp plugin for bundle up the html files, css files and javascript file", "keywords": [ "gulpplugin",