From 7c3efd28a4d3787ce9cf7f90b1feb5de3a1c38eb Mon Sep 17 00:00:00 2001 From: Evgeni Dmitriev Date: Mon, 22 Feb 2016 20:23:24 +0300 Subject: [PATCH] Add "resolve url nocheck". Fixes #146 --- Gruntfile.js | 8 ++++++++ README.md | 8 ++++++++ docs/stylus-options.md | 8 ++++++++ tasks/stylus.js | 2 ++ test/expected/resolveUrlNocheck/resolveUrlNocheck.css | 1 + test/fixtures/resolveUrlNocheck/child/both.styl | 2 ++ test/fixtures/resolveUrlNocheck/child/child.styl | 2 ++ test/fixtures/resolveUrlNocheck/child/vars.styl | 1 + test/fixtures/resolveUrlNocheck/other/child.styl | 0 test/fixtures/resolveUrlNocheck/other/vars.styl | 0 test/fixtures/resolveUrlNocheck/resolveUrlNocheck.styl | 1 + test/stylus_test.js | 9 +++++++++ 12 files changed, 42 insertions(+) create mode 100644 test/expected/resolveUrlNocheck/resolveUrlNocheck.css create mode 100644 test/fixtures/resolveUrlNocheck/child/both.styl create mode 100644 test/fixtures/resolveUrlNocheck/child/child.styl create mode 100644 test/fixtures/resolveUrlNocheck/child/vars.styl create mode 100644 test/fixtures/resolveUrlNocheck/other/child.styl create mode 100644 test/fixtures/resolveUrlNocheck/other/vars.styl create mode 100644 test/fixtures/resolveUrlNocheck/resolveUrlNocheck.styl diff --git a/Gruntfile.js b/Gruntfile.js index 694f38f..178938a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -160,6 +160,14 @@ module.exports = function(grunt) { 'resolve url': true } }, + resolveUrlNocheck: { + files: { + 'tmp/resolveUrlNocheck.css': 'test/fixtures/resolveUrlNocheck/resolveUrlNocheck.styl' + }, + options: { + 'resolve url nocheck': true + } + }, import: { files: { 'tmp/import.css': 'test/fixtures/import/import.styl' diff --git a/README.md b/README.md index 902e783..b7afa3b 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,14 @@ _All urls are resolved relatively to position of resulting `.css` file_ ( **NOTICE:** the object key contains a space `"resolve url"` and Stylus resolves the url only if it finds the provided file ) +#### [resolve url nocheck] +Type: `Boolean` +Default: `false` + +Like [resolve url](#resolve-url), but without file existence check. Fixes [some current issues](https://github.com/stylus/stylus/issues/2119). + +( **NOTICE:** the object key contains spaces `"resolve url nocheck"` ) + #### banner Type: `String` Default: `''` diff --git a/docs/stylus-options.md b/docs/stylus-options.md index 82909ec..5de34a9 100644 --- a/docs/stylus-options.md +++ b/docs/stylus-options.md @@ -76,6 +76,14 @@ _All urls are resolved relatively to position of resulting `.css` file_ ( **NOTICE:** the object key contains a space `"resolve url"` and Stylus resolves the url only if it finds the provided file ) +## resolve url nocheck +Type: `Boolean` +Default: `false` + +Like [resolve url(#resolve-url), but without file existence check. Fixing [some current issues](https://github.com/stylus/stylus/issues/2119). + +( **NOTICE:** the object key contains two spaces `"resolve url nocheck"` ) + ## banner Type: `String` Default: `''` diff --git a/tasks/stylus.js b/tasks/stylus.js index 01fb526..d1867b6 100644 --- a/tasks/stylus.js +++ b/tasks/stylus.js @@ -68,6 +68,8 @@ module.exports = function(grunt) { }); } else if (key === 'resolve url') { s.define('url', stylus.resolver()); + } else if (key === 'resolve url nocheck') { + s.define('url', stylus.resolver({nocheck: true})); } else { s.set(key, value); } diff --git a/test/expected/resolveUrlNocheck/resolveUrlNocheck.css b/test/expected/resolveUrlNocheck/resolveUrlNocheck.css new file mode 100644 index 0000000..26d51c5 --- /dev/null +++ b/test/expected/resolveUrlNocheck/resolveUrlNocheck.css @@ -0,0 +1 @@ +body{background:url("../test/fixtures/resolveUrlNocheck/child/child.png")} \ No newline at end of file diff --git a/test/fixtures/resolveUrlNocheck/child/both.styl b/test/fixtures/resolveUrlNocheck/child/both.styl new file mode 100644 index 0000000..69014c5 --- /dev/null +++ b/test/fixtures/resolveUrlNocheck/child/both.styl @@ -0,0 +1,2 @@ +@import 'vars.styl' +@import 'child.styl' diff --git a/test/fixtures/resolveUrlNocheck/child/child.styl b/test/fixtures/resolveUrlNocheck/child/child.styl new file mode 100644 index 0000000..a6972b3 --- /dev/null +++ b/test/fixtures/resolveUrlNocheck/child/child.styl @@ -0,0 +1,2 @@ +body + background: url("child.png") diff --git a/test/fixtures/resolveUrlNocheck/child/vars.styl b/test/fixtures/resolveUrlNocheck/child/vars.styl new file mode 100644 index 0000000..f83fee1 --- /dev/null +++ b/test/fixtures/resolveUrlNocheck/child/vars.styl @@ -0,0 +1 @@ +@import '../other/vars.styl' diff --git a/test/fixtures/resolveUrlNocheck/other/child.styl b/test/fixtures/resolveUrlNocheck/other/child.styl new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/resolveUrlNocheck/other/vars.styl b/test/fixtures/resolveUrlNocheck/other/vars.styl new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/resolveUrlNocheck/resolveUrlNocheck.styl b/test/fixtures/resolveUrlNocheck/resolveUrlNocheck.styl new file mode 100644 index 0000000..94d5236 --- /dev/null +++ b/test/fixtures/resolveUrlNocheck/resolveUrlNocheck.styl @@ -0,0 +1 @@ +@import "child/both.styl" diff --git a/test/stylus_test.js b/test/stylus_test.js index 22baadf..60d5f77 100644 --- a/test/stylus_test.js +++ b/test/stylus_test.js @@ -128,6 +128,15 @@ exports.stylus = { test.done(); }, + resolveUrlNocheck: function(test) { + test.expect(1); + + var actual = readFile('tmp/resolveUrlNocheck.css'); + var expected = readFile('test/expected/resolveUrlNocheck/resolveUrlNocheck.css'); + test.equal(expected, actual, 'should resolve import urls without existence check'); + + test.done(); + }, relativeDestIn: function(test) { test.expect(1);