diff --git a/index.js b/index.js index 2a1f135..95625c9 100644 --- a/index.js +++ b/index.js @@ -8,10 +8,10 @@ module.exports = function(options){ } function transform(options) { - options = options || {} return function(file, enc, cb){ var contents var transformed + var options = options || {} if(file.isStream()) { return cb( new PluginError("gulp-cssnext", "streaming not supported") diff --git a/test/cssnext.js b/test/cssnext.js index e859e9b..c92263a 100644 --- a/test/cssnext.js +++ b/test/cssnext.js @@ -67,3 +67,46 @@ tape("throws on cssnext error", function(test){ }) stream.end(file) }) + +tape("Resolves relative paths for consecutive files in different paths", function(test) { + var stream = cssnext() + var file = new gutil.File({ + base: "./fixtures/", + path: "./fixtures/import.css", + contents: new Buffer( + fs.readFileSync( + path.resolve(__dirname, "./fixtures/import.css"), + "utf8" + ) + ) + }) + stream.write(file) + + var file2 = new gutil.File({ + base : "./fixtures/import/", + path : "./fixtures/import/index.css", + contents : new Buffer( + fs.readFileSync( + path.resolve(__dirname, "./fixtures/import/index.css"), + "utf8" + ) + ) + }) + stream.write(file2) + + var count = 0; + stream.on("data", function(file){ + + test.equal( + file.contents.toString(), + fs.readFileSync( + path.resolve(__dirname, "./expected/index.css"), + "utf8" + ) + ) + ++count + if(count == 2) { + test.end() + } + }) +}) diff --git a/test/fixtures/import.css b/test/fixtures/import.css new file mode 100644 index 0000000..90be5f7 --- /dev/null +++ b/test/fixtures/import.css @@ -0,0 +1 @@ +@import './index.css'; diff --git a/test/fixtures/import/index.css b/test/fixtures/import/index.css new file mode 100644 index 0000000..011e968 --- /dev/null +++ b/test/fixtures/import/index.css @@ -0,0 +1 @@ +@import '../index.css';