diff --git a/.eslintrc b/.eslintrc index 0eea4a1..f5f81cd 100644 --- a/.eslintrc +++ b/.eslintrc @@ -152,4 +152,3 @@ rules: - always - propertyName: false singleValue: false - diff --git a/.travis.yml b/.travis.yml index e5da3fa..8a536bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,15 @@ +# Configuration options are documented at: +# http://docs.travis-ci.com/user/languages/javascript-with-nodejs/ language: node_js node_js: - - "0.10" - - node + - '0.10' + - '0.12' + - '4.0' + - '4.1' + - '5.0' - iojs -before_install: +before_script: - npm install -g bower - - cd tests + - cd test - bower install -f - cd .. diff --git a/index.js b/index.js index 8c02aac..7b12d9f 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,7 @@ var importOnce = function importOnce(data, done) { * they leave off the partial prefix and the suffix. * This code creates the possible extensions, whether it is a partial * and whether it is a directory index file having those - * same possible variations. If the import contains an extension, + * same possible variations. If the import contains a valid extension, * then it is left alone. * **/ @@ -51,6 +51,8 @@ var getFileNames = function getFileNames(abstractName) { directory, basename; + // If the name has a Sass extension, treat it as a path to a real file, and as a fallback + // look for the same file with a prefix. if ([ '.scss', '.sass' ].indexOf(path.extname(abstractName)) !== -1) { directory = path.dirname(abstractName); basename = path.basename(abstractName); @@ -59,9 +61,11 @@ var getFileNames = function getFileNames(abstractName) { names.push(path.join(directory, prefix + basename)); }); } - else if (path.extname(abstractName)) { + // If the name has a different valid extension, treat it as a path to a real file. + else if ([ '.css', '.json', '.yaml' ].indexOf(path.extname(abstractName)) !== -1) { names.push(abstractName); } + // Otherwise, the name is abstract and all variants should be searched. else { directory = path.dirname(abstractName); basename = path.basename(abstractName); @@ -308,7 +312,7 @@ var importer = function importer(uri, prev, done) { file = path.resolve(path.dirname(prev), makeFsPath(uri)); raf(uri, file, function (err, data) { if (err) { - console.log(err.toString()); + console.log(err.toString()); // eslint-disable-line no-console done({}); } else { @@ -319,7 +323,7 @@ var importer = function importer(uri, prev, done) { else { raf(uri, process.cwd(), function (err, data) { if (err) { - console.log(err.toString()); + console.log(err.toString()); // eslint-disable-line no-console done({}); } else { diff --git a/package.json b/package.json index 69ecdbf..954056e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Custom importer for node-sass that only allows a file to be imported once. Includes additional import bonuses including importing CSS files directly into Sass, automagic Bower imports, the ability to import an `index` file from within a folder name, and the ability to import JSON and YAML files as Sass maps. Inspired by Eyeglass.", "main": "index.js", "scripts": { - "test": "cd tests && ../node_modules/.bin/mocha ./" + "test": "mocha" }, "repository": { "type": "git", diff --git a/test/.bowerrc b/test/.bowerrc new file mode 100644 index 0000000..f5b3477 --- /dev/null +++ b/test/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "../bower_components" +} diff --git a/tests/bower.json b/test/bower.json similarity index 91% rename from tests/bower.json rename to test/bower.json index 2331f3d..89cf546 100644 --- a/tests/bower.json +++ b/test/bower.json @@ -7,7 +7,7 @@ ], "license": "MIT", "devDependencies": { - "bootstrap": "~3.3.4", + "bootstrap": "3.3.4", "sass-toolkit": "~2.9.0", "breakpoint-sass": "~2.5.0" } diff --git a/tests/css/basic-import-once.css b/test/css/basic-import-once.css similarity index 100% rename from tests/css/basic-import-once.css rename to test/css/basic-import-once.css diff --git a/test/css/import-with-dot.css b/test/css/import-with-dot.css new file mode 100644 index 0000000..4606e41 --- /dev/null +++ b/test/css/import-with-dot.css @@ -0,0 +1,2 @@ +.some-class-in-dotted-file { + color: blue; } diff --git a/tests/css/imported-bootstrap.css b/test/css/imported-bootstrap.css similarity index 97% rename from tests/css/imported-bootstrap.css rename to test/css/imported-bootstrap.css index d5e71b4..0da5c2b 100644 --- a/tests/css/imported-bootstrap.css +++ b/test/css/imported-bootstrap.css @@ -60,7 +60,7 @@ dfn { font-style: italic; } h1 { - margin: 0.67em 0; + margin: .67em 0; font-size: 2em; } mark { @@ -165,7 +165,7 @@ input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } fieldset { - padding: 0.35em 0.625em 0.75em; + padding: .35em .625em .75em; margin: 0 2px; border: 1px solid #c0c0c0; } @@ -230,9 +230,9 @@ th { background: #fff !important; } .navbar { display: none; } - .btn > .caret, - .button > .caret, - .dropup > .btn > .caret, .dropup > .button > .caret { + .btn > .caret, .button > .caret, + .dropup > .btn > .caret, + .dropup > .button > .caret { border-top-color: #000 !important; } .label { border: 1px solid #000; } @@ -1119,9 +1119,9 @@ img { background-color: #fff; border: 1px solid #ddd; border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - -o-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; } + -webkit-transition: all .2s ease-in-out; + -o-transition: all .2s ease-in-out; + transition: all .2s ease-in-out; } .img-circle { border-radius: 50%; } @@ -2365,9 +2365,9 @@ output { border-radius: 4px; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out 0.15s, -webkit-box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; } + -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s; + -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; } .form-control:focus { border-color: #66afe9; @@ -2772,7 +2772,7 @@ select[multiple].form-group-lg .form-control { @media (min-width: 768px) { .form-horizontal .form-group-lg .control-label { - padding-top: 14.33333px; } } + padding-top: 14.333333px; } } @media (min-width: 768px) { .form-horizontal .form-group-sm .control-label { @@ -2799,8 +2799,7 @@ select[multiple].form-group-lg .form-control { border: 1px solid transparent; border-radius: 4px; } -.btn:focus, -.button:focus, +.btn:focus, .button:focus, .btn:active:focus, .button:active:focus, .btn.active:focus, @@ -2809,32 +2808,33 @@ select[multiple].form-group-lg .form-control { .focus.button, .btn:active.focus, .button:active.focus, -.btn.active.focus, .active.focus.button { +.btn.active.focus, +.active.focus.button { outline: thin dotted; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } -.btn:hover, -.button:hover, +.btn:hover, .button:hover, .btn:focus, .button:focus, -.btn.focus, .focus.button { +.btn.focus, +.focus.button { color: #333; text-decoration: none; } -.btn:active, -.button:active, -.btn.active, .active.button { +.btn:active, .button:active, +.btn.active, +.active.button { background-image: none; outline: 0; -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); } -.btn.disabled, -.disabled.button, +.btn.disabled, .disabled.button, .btn[disabled], [disabled].button, -fieldset[disabled] .btn, fieldset[disabled] .button { +fieldset[disabled] .btn, +fieldset[disabled] .button { pointer-events: none; cursor: not-allowed; filter: alpha(opacity=65); @@ -3146,21 +3146,24 @@ fieldset[disabled] .btn-link:focus { text-decoration: none; } .btn-lg, -.btn-group-lg > .btn, .btn-group-lg > .button { +.btn-group-lg > .btn, +.btn-group-lg > .button { padding: 10px 16px; font-size: 18px; line-height: 1.3333333; border-radius: 6px; } .btn-sm, -.btn-group-sm > .btn, .btn-group-sm > .button { +.btn-group-sm > .btn, +.btn-group-sm > .button { padding: 5px 10px; font-size: 12px; line-height: 1.5; border-radius: 3px; } .btn-xs, -.btn-group-xs > .btn, .btn-group-xs > .button { +.btn-group-xs > .btn, +.btn-group-xs > .button { padding: 1px 5px; font-size: 12px; line-height: 1.5; @@ -3180,9 +3183,9 @@ input[type="button"].btn-block { .fade { opacity: 0; - -webkit-transition: opacity 0.15s linear; - -o-transition: opacity 0.15s linear; - transition: opacity 0.15s linear; } + -webkit-transition: opacity .15s linear; + -o-transition: opacity .15s linear; + transition: opacity .15s linear; } .fade.in { opacity: 1; } @@ -3358,14 +3361,13 @@ tbody.collapse.in { display: inline-block; vertical-align: middle; } -.btn-group > .btn, -.btn-group > .button, -.btn-group-vertical > .btn, .btn-group-vertical > .button { +.btn-group > .btn, .btn-group > .button, +.btn-group-vertical > .btn, +.btn-group-vertical > .button { position: relative; float: left; } -.btn-group > .btn:hover, -.btn-group > .button:hover, +.btn-group > .btn:hover, .btn-group > .button:hover, .btn-group-vertical > .btn:hover, .btn-group-vertical > .button:hover, .btn-group > .btn:focus, @@ -3378,13 +3380,11 @@ tbody.collapse.in { .btn-group-vertical > .button:active, .btn-group > .btn.active, .btn-group > .active.button, -.btn-group-vertical > .btn.active, .btn-group-vertical > .active.button { +.btn-group-vertical > .btn.active, +.btn-group-vertical > .active.button { z-index: 2; } -.btn-group .btn + .btn, -.btn-group .button + .btn, -.btn-group .btn + .button, -.btn-group .button + .button, +.btn-group .btn + .btn, .btn-group .button + .btn, .btn-group .btn + .button, .btn-group .button + .button, .btn-group .btn + .btn-group, .btn-group .button + .btn-group, .btn-group .btn-group + .btn, @@ -3399,8 +3399,7 @@ tbody.collapse.in { .btn-toolbar .input-group { float: left; } -.btn-toolbar > .btn, -.btn-toolbar > .button, +.btn-toolbar > .btn, .btn-toolbar > .button, .btn-toolbar > .btn-group, .btn-toolbar > .input-group { margin-left: 5px; } @@ -3415,8 +3414,7 @@ tbody.collapse.in { border-top-right-radius: 0; border-bottom-right-radius: 0; } -.btn-group > .btn:last-child:not(:first-child), -.btn-group > .button:last-child:not(:first-child), +.btn-group > .btn:last-child:not(:first-child), .btn-group > .button:last-child:not(:first-child), .btn-group > .dropdown-toggle:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; } @@ -3427,8 +3425,7 @@ tbody.collapse.in { .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn, .btn-group > .btn-group:not(:first-child):not(:last-child) > .button { border-radius: 0; } -.btn-group > .btn-group:first-child:not(:last-child) > .btn:last-child, -.btn-group > .btn-group:first-child:not(:last-child) > .button:last-child, +.btn-group > .btn-group:first-child:not(:last-child) > .btn:last-child, .btn-group > .btn-group:first-child:not(:last-child) > .button:last-child, .btn-group > .btn-group:first-child:not(:last-child) > .dropdown-toggle { border-top-right-radius: 0; border-bottom-right-radius: 0; } @@ -3467,10 +3464,10 @@ tbody.collapse.in { .dropup .btn-lg .caret { border-width: 0 5px 5px; } -.btn-group-vertical > .btn, -.btn-group-vertical > .button, +.btn-group-vertical > .btn, .btn-group-vertical > .button, .btn-group-vertical > .btn-group, -.btn-group-vertical > .btn-group > .btn, .btn-group-vertical > .btn-group > .button { +.btn-group-vertical > .btn-group > .btn, +.btn-group-vertical > .btn-group > .button { display: block; float: none; width: 100%; @@ -3479,10 +3476,7 @@ tbody.collapse.in { .btn-group-vertical > .btn-group > .btn, .btn-group-vertical > .btn-group > .button { float: none; } -.btn-group-vertical > .btn + .btn, -.btn-group-vertical > .button + .btn, -.btn-group-vertical > .btn + .button, -.btn-group-vertical > .button + .button, +.btn-group-vertical > .btn + .btn, .btn-group-vertical > .button + .btn, .btn-group-vertical > .btn + .button, .btn-group-vertical > .button + .button, .btn-group-vertical > .btn + .btn-group, .btn-group-vertical > .button + .btn-group, .btn-group-vertical > .btn-group + .btn, @@ -3507,8 +3501,7 @@ tbody.collapse.in { .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn, .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .button { border-radius: 0; } -.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child, -.btn-group-vertical > .btn-group:first-child:not(:last-child) > .button:last-child, +.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child, .btn-group-vertical > .btn-group:first-child:not(:last-child) > .button:last-child, .btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle { border-bottom-right-radius: 0; border-bottom-left-radius: 0; } @@ -3523,8 +3516,7 @@ tbody.collapse.in { table-layout: fixed; border-collapse: separate; } -.btn-group-justified > .btn, -.btn-group-justified > .button, +.btn-group-justified > .btn, .btn-group-justified > .button, .btn-group-justified > .btn-group { display: table-cell; float: none; @@ -3536,13 +3528,13 @@ tbody.collapse.in { .btn-group-justified > .btn-group .dropdown-menu { left: auto; } -[data-toggle="buttons"] > .btn input[type="radio"], -[data-toggle="buttons"] > .button input[type="radio"], +[data-toggle="buttons"] > .btn input[type="radio"], [data-toggle="buttons"] > .button input[type="radio"], [data-toggle="buttons"] > .btn-group > .btn input[type="radio"], [data-toggle="buttons"] > .btn-group > .button input[type="radio"], [data-toggle="buttons"] > .btn input[type="checkbox"], [data-toggle="buttons"] > .button input[type="checkbox"], -[data-toggle="buttons"] > .btn-group > .btn input[type="checkbox"], [data-toggle="buttons"] > .btn-group > .button input[type="checkbox"] { +[data-toggle="buttons"] > .btn-group > .btn input[type="checkbox"], +[data-toggle="buttons"] > .btn-group > .button input[type="checkbox"] { position: absolute; clip: rect(0, 0, 0, 0); pointer-events: none; } @@ -3566,7 +3558,8 @@ tbody.collapse.in { .input-group-lg > .form-control, .input-group-lg > .input-group-addon, -.input-group-lg > .input-group-btn > .btn, .input-group-lg > .input-group-btn > .button { +.input-group-lg > .input-group-btn > .btn, +.input-group-lg > .input-group-btn > .button { height: 46px; padding: 10px 16px; font-size: 18px; @@ -3575,7 +3568,8 @@ tbody.collapse.in { select.input-group-lg > .form-control, select.input-group-lg > .input-group-addon, -select.input-group-lg > .input-group-btn > .btn, select.input-group-lg > .input-group-btn > .button { +select.input-group-lg > .input-group-btn > .btn, +select.input-group-lg > .input-group-btn > .button { height: 46px; line-height: 46px; } @@ -3585,12 +3579,14 @@ textarea.input-group-lg > .input-group-btn > .btn, textarea.input-group-lg > .input-group-btn > .button, select[multiple].input-group-lg > .form-control, select[multiple].input-group-lg > .input-group-addon, -select[multiple].input-group-lg > .input-group-btn > .btn, select[multiple].input-group-lg > .input-group-btn > .button { +select[multiple].input-group-lg > .input-group-btn > .btn, +select[multiple].input-group-lg > .input-group-btn > .button { height: auto; } .input-group-sm > .form-control, .input-group-sm > .input-group-addon, -.input-group-sm > .input-group-btn > .btn, .input-group-sm > .input-group-btn > .button { +.input-group-sm > .input-group-btn > .btn, +.input-group-sm > .input-group-btn > .button { height: 30px; padding: 5px 10px; font-size: 12px; @@ -3599,7 +3595,8 @@ select[multiple].input-group-lg > .input-group-btn > .btn, select[multiple].inpu select.input-group-sm > .form-control, select.input-group-sm > .input-group-addon, -select.input-group-sm > .input-group-btn > .btn, select.input-group-sm > .input-group-btn > .button { +select.input-group-sm > .input-group-btn > .btn, +select.input-group-sm > .input-group-btn > .button { height: 30px; line-height: 30px; } @@ -3609,7 +3606,8 @@ textarea.input-group-sm > .input-group-btn > .btn, textarea.input-group-sm > .input-group-btn > .button, select[multiple].input-group-sm > .form-control, select[multiple].input-group-sm > .input-group-addon, -select[multiple].input-group-sm > .input-group-btn > .btn, select[multiple].input-group-sm > .input-group-btn > .button { +select[multiple].input-group-sm > .input-group-btn > .btn, +select[multiple].input-group-sm > .input-group-btn > .button { height: auto; } .input-group-addon, @@ -3662,7 +3660,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn, select[multiple].inpu .input-group-btn:first-child > .dropdown-toggle, .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle), .input-group-btn:last-child > .button:not(:last-child):not(.dropdown-toggle), -.input-group-btn:last-child > .btn-group:not(:last-child) > .btn, .input-group-btn:last-child > .btn-group:not(:last-child) > .button { +.input-group-btn:last-child > .btn-group:not(:last-child) > .btn, +.input-group-btn:last-child > .btn-group:not(:last-child) > .button { border-top-right-radius: 0; border-bottom-right-radius: 0; } @@ -3678,7 +3677,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn, select[multiple].inpu .input-group-btn:last-child > .dropdown-toggle, .input-group-btn:first-child > .btn:not(:first-child), .input-group-btn:first-child > .button:not(:first-child), -.input-group-btn:first-child > .btn-group:not(:first-child) > .btn, .input-group-btn:first-child > .btn-group:not(:first-child) > .button { +.input-group-btn:first-child > .btn-group:not(:first-child) > .btn, +.input-group-btn:first-child > .btn-group:not(:first-child) > .button { border-top-left-radius: 0; border-bottom-left-radius: 0; } @@ -3696,20 +3696,18 @@ select[multiple].input-group-sm > .input-group-btn > .btn, select[multiple].inpu .input-group-btn > .btn + .btn, .input-group-btn > .button + .btn, .input-group-btn > .btn + .button, .input-group-btn > .button + .button { margin-left: -1px; } -.input-group-btn > .btn:hover, -.input-group-btn > .button:hover, +.input-group-btn > .btn:hover, .input-group-btn > .button:hover, .input-group-btn > .btn:focus, .input-group-btn > .button:focus, -.input-group-btn > .btn:active, .input-group-btn > .button:active { +.input-group-btn > .btn:active, +.input-group-btn > .button:active { z-index: 2; } -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .button, +.input-group-btn:first-child > .btn, .input-group-btn:first-child > .button, .input-group-btn:first-child > .btn-group { margin-right: -1px; } -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .button, +.input-group-btn:last-child > .btn, .input-group-btn:last-child > .button, .input-group-btn:last-child > .btn-group { margin-left: -1px; } @@ -4528,7 +4526,7 @@ fieldset[disabled] .navbar-inverse .btn-link:focus { .label { display: inline; - padding: 0.2em 0.6em 0.3em; + padding: .2em .6em .3em; font-size: 75%; font-weight: bold; line-height: 1; @@ -4615,7 +4613,8 @@ a.label:focus { top: -1px; } .btn-xs .badge, -.btn-group-xs > .btn .badge, .btn-group-xs > .button .badge { +.btn-group-xs > .btn .badge, +.btn-group-xs > .button .badge { top: 0; padding: 1px 5px; } @@ -4683,9 +4682,9 @@ a.badge:focus { background-color: #fff; border: 1px solid #ddd; border-radius: 4px; - -webkit-transition: border 0.2s ease-in-out; - -o-transition: border 0.2s ease-in-out; - transition: border 0.2s ease-in-out; } + -webkit-transition: border .2s ease-in-out; + -o-transition: border .2s ease-in-out; + transition: border .2s ease-in-out; } .thumbnail > img, .thumbnail a > img { @@ -4814,9 +4813,9 @@ a.thumbnail.active { background-color: #337ab7; -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-transition: width 0.6s ease; - -o-transition: width 0.6s ease; - transition: width 0.6s ease; } + -webkit-transition: width .6s ease; + -o-transition: width .6s ease; + transition: width .6s ease; } .progress-striped .progress-bar, .progress-bar-striped { @@ -5507,9 +5506,9 @@ button.close { outline: 0; } .modal.fade .modal-dialog { - -webkit-transition: -webkit-transform 0.3s ease-out; - -o-transition: -o-transform 0.3s ease-out; - transition: transform 0.3s ease-out; + -webkit-transition: -webkit-transform .3s ease-out; + -o-transition: -o-transform .3s ease-out; + transition: transform .3s ease-out; -webkit-transform: translate(0, -25%); -ms-transform: translate(0, -25%); -o-transform: translate(0, -25%); @@ -5560,7 +5559,7 @@ button.close { opacity: .5; } .modal-header { - min-height: 16.42857px; + min-height: 16.42857143px; padding: 15px; border-bottom: 1px solid #e5e5e5; } @@ -5847,9 +5846,9 @@ button.close { .carousel-inner > .item { position: relative; display: none; - -webkit-transition: 0.6s ease-in-out left; - -o-transition: 0.6s ease-in-out left; - transition: 0.6s ease-in-out left; } + -webkit-transition: .6s ease-in-out left; + -o-transition: .6s ease-in-out left; + transition: .6s ease-in-out left; } .carousel-inner > .item > img, .carousel-inner > .item > a > img { @@ -5857,9 +5856,9 @@ button.close { @media all and (transform-3d), (-webkit-transform-3d) { .carousel-inner > .item { - -webkit-transition: -webkit-transform 0.6s ease-in-out; - -o-transition: -o-transform 0.6s ease-in-out; - transition: transform 0.6s ease-in-out; + -webkit-transition: -webkit-transform .6s ease-in-out; + -o-transition: -o-transform .6s ease-in-out; + transition: transform .6s ease-in-out; -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-perspective: 1000; diff --git a/tests/css/imported-bower.css b/test/css/imported-bower.css similarity index 100% rename from tests/css/imported-bower.css rename to test/css/imported-bower.css diff --git a/tests/css/imported-css.css b/test/css/imported-css.css similarity index 100% rename from tests/css/imported-css.css rename to test/css/imported-css.css diff --git a/tests/css/imported-custom.css b/test/css/imported-custom.css similarity index 100% rename from tests/css/imported-custom.css rename to test/css/imported-custom.css diff --git a/tests/css/imported-index.css b/test/css/imported-index.css similarity index 100% rename from tests/css/imported-index.css rename to test/css/imported-index.css diff --git a/tests/css/imported-json.css b/test/css/imported-json.css similarity index 100% rename from tests/css/imported-json.css rename to test/css/imported-json.css diff --git a/tests/css/imported-scss.css b/test/css/imported-scss.css similarity index 100% rename from tests/css/imported-scss.css rename to test/css/imported-scss.css diff --git a/tests/custom/_custom-import.scss b/test/custom/_custom-import.scss similarity index 100% rename from tests/custom/_custom-import.scss rename to test/custom/_custom-import.scss diff --git a/tests/lint.js b/test/lint.js similarity index 89% rename from tests/lint.js rename to test/lint.js index 4e1b47b..ced68d3 100644 --- a/tests/lint.js +++ b/test/lint.js @@ -15,7 +15,7 @@ describe('code style guide', function() { 'no-console': 0 } }); - report = cli.executeOnFiles(['../index.js']); + report = cli.executeOnFiles(['index.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); } @@ -31,7 +31,7 @@ describe('code style guide', function() { 'no-console': 2 } }); - report = cli.executeOnFiles(['main.js']); + report = cli.executeOnFiles(['test/main.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); } @@ -47,7 +47,7 @@ describe('code style guide', function() { 'no-console': 0 } }); - report = cli.executeOnFiles(['lint.js']); + report = cli.executeOnFiles(['test/lint.js']); if (report.errorCount > 0 || report.warningCount > 0) { console.log(formatter(report.results)); } diff --git a/tests/main.js b/test/main.js similarity index 67% rename from tests/main.js rename to test/main.js index 2fdf5dc..e59d9e9 100644 --- a/tests/main.js +++ b/test/main.js @@ -7,7 +7,10 @@ var should = require('should'), importer = require('../index'); var filePath = function (file) { - return path.join(path.join(__dirname, 'sass'), file); + return path.join(__dirname, 'sass', file); +}; +var bowerPath = function (file) { + return path.join(__dirname, '../bower_components', file); }; describe('import-once', function () { @@ -15,6 +18,7 @@ describe('import-once', function () { var file = filePath('basic-import-once.scss'), expectedIncludes = [ file, + filePath('_partial-with-selectors.scss'), 'partial-with-selectors' ]; @@ -34,34 +38,34 @@ describe('import-once', function () { }); }); - it.only('should resolve import with Sass extensions', function(done) { + it('should resolve import with Sass extensions', function(done) { var file = filePath('import-scss.scss'), expectedIncludes = [ file, filePath('foo/_index.scss') ]; - sass.render({ - 'file': file, - 'importer': importer - }, function (err, result) { - if (err) { - throw err; - } - should.exist(result); - result.stats.includedFiles.should.eql(expectedIncludes); - String(result.css).should.equal( - fs.readFileSync(path.join(__dirname, 'css/imported-scss.css'), 'utf8') - ); - done(); - }); - }) + sass.render({ + 'file': file, + 'importer': importer + }, function (err, result) { + if (err) { + throw err; + } + should.exist(result); + result.stats.includedFiles.should.eql(expectedIncludes); + String(result.css).should.equal( + fs.readFileSync(path.join(__dirname, 'css/imported-scss.css'), 'utf8') + ); + done(); + }); + }); it('should import `index` files from a folder', function (done) { var file = filePath('import-index.scss'), expectedIncludes = [ file, - 'foo' + filePath('foo/_index.scss') ]; sass.render({ @@ -87,7 +91,7 @@ describe('import-once', function () { var file = filePath('import-css.scss'), expectedIncludes = [ file, - 'imported-css' + filePath('imported-css.css') ]; sass.render({ @@ -114,24 +118,24 @@ describe('import-once', function () { var file = filePath('import-bower.scss'), expectedIncludes = [ file, - 'breakpoint', - 'breakpoint/context', - 'breakpoint/helpers', - 'breakpoint/no-query', - 'breakpoint/parsers', - 'breakpoint/respond-to', - 'double/default', - 'double/default-pair', - 'double/double-string', - 'parsers/double', - 'parsers/query', - 'parsers/resolution', - 'parsers/single', - 'parsers/triple', - 'resolution/resolution', - 'single/default', - 'toolkit/kickstart', - 'triple/default' + bowerPath('breakpoint-sass/stylesheets/_breakpoint.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/_context.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/_helpers.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/_no-query.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/_parsers.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/_respond-to.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/_double.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/_query.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/_resolution.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/_single.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/_triple.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/double/_default-pair.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/double/_default.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/double/_double-string.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/resolution/_resolution.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/single/_default.scss'), + bowerPath('breakpoint-sass/stylesheets/breakpoint/parsers/triple/_default.scss'), + bowerPath('sass-toolkit/stylesheets/toolkit/_kickstart.scss') ]; sass.render({ @@ -158,7 +162,7 @@ describe('import-once', function () { var file = filePath('import-json.scss'), expectedIncludes = [ file, - 'colors.json' + filePath('colors.json') ]; sass.render({ @@ -183,7 +187,7 @@ describe('import-once', function () { var file = filePath('import-yaml.scss'), expectedIncludes = [ file, - 'colors.yaml' + filePath('colors.yaml') ]; sass.render({ @@ -208,6 +212,7 @@ describe('import-once', function () { var file = filePath('import-custom.scss'), expectedIncludes = [ file, + filePath('../custom/_custom-import.scss'), 'custom-import' ]; @@ -215,7 +220,7 @@ describe('import-once', function () { 'file': file, 'importer': importer, 'includePaths': [ - 'custom' + 'test/custom' ] }, function (err, result) { if (err) { @@ -236,7 +241,7 @@ describe('import-once', function () { var file = filePath('import-bootstrap.scss'), expectedIncludes = [ file, - 'bootstrap' + bowerPath('bootstrap/dist/css/bootstrap.css') ]; sass.render({ @@ -263,6 +268,7 @@ describe('import-once', function () { it('should fall back to import paths and bower if data is passed in instead of a file name', function (done) { var file = filePath('basic-import-once.scss'), expectedIncludes = [ + filePath('_partial-with-selectors.scss'), 'partial-with-selectors' ]; @@ -284,4 +290,27 @@ describe('import-once', function () { done(); }); }); + + it('should import a file with dots in its name', function(done) { + var file = filePath('import-with-dot.scss'), + expectedIncludes = [ + file, + filePath('file.with.dot.scss') + ]; + + sass.render({ + 'file': file, + 'importer': importer + }, function(err, result) { + if (err) { + throw err; + } + should.exist(result); + result.stats.includedFiles.should.eql(expectedIncludes); + String(result.css).should.equal( + fs.readFileSync(path.join(__dirname, 'css/import-with-dot.css'), 'utf8') + ); + done(); + }); + }); }); diff --git a/tests/sass/_partial-with-selectors.scss b/test/sass/_partial-with-selectors.scss similarity index 100% rename from tests/sass/_partial-with-selectors.scss rename to test/sass/_partial-with-selectors.scss diff --git a/tests/sass/basic-import-once.scss b/test/sass/basic-import-once.scss similarity index 100% rename from tests/sass/basic-import-once.scss rename to test/sass/basic-import-once.scss diff --git a/tests/sass/colors.json b/test/sass/colors.json similarity index 100% rename from tests/sass/colors.json rename to test/sass/colors.json diff --git a/tests/sass/colors.yaml b/test/sass/colors.yaml similarity index 100% rename from tests/sass/colors.yaml rename to test/sass/colors.yaml diff --git a/test/sass/file.with.dot.scss b/test/sass/file.with.dot.scss new file mode 100644 index 0000000..7f65038 --- /dev/null +++ b/test/sass/file.with.dot.scss @@ -0,0 +1,3 @@ +.some-class-in-dotted-file { + color: blue; +} diff --git a/tests/sass/foo/_index.scss b/test/sass/foo/_index.scss similarity index 100% rename from tests/sass/foo/_index.scss rename to test/sass/foo/_index.scss diff --git a/tests/sass/import-bootstrap.scss b/test/sass/import-bootstrap.scss similarity index 100% rename from tests/sass/import-bootstrap.scss rename to test/sass/import-bootstrap.scss diff --git a/tests/sass/import-bower.scss b/test/sass/import-bower.scss similarity index 100% rename from tests/sass/import-bower.scss rename to test/sass/import-bower.scss diff --git a/tests/sass/import-css.scss b/test/sass/import-css.scss similarity index 100% rename from tests/sass/import-css.scss rename to test/sass/import-css.scss diff --git a/tests/sass/import-custom.scss b/test/sass/import-custom.scss similarity index 100% rename from tests/sass/import-custom.scss rename to test/sass/import-custom.scss diff --git a/tests/sass/import-index.scss b/test/sass/import-index.scss similarity index 100% rename from tests/sass/import-index.scss rename to test/sass/import-index.scss diff --git a/tests/sass/import-json.scss b/test/sass/import-json.scss similarity index 100% rename from tests/sass/import-json.scss rename to test/sass/import-json.scss diff --git a/tests/sass/import-scss.scss b/test/sass/import-scss.scss similarity index 100% rename from tests/sass/import-scss.scss rename to test/sass/import-scss.scss diff --git a/test/sass/import-with-dot.scss b/test/sass/import-with-dot.scss new file mode 100644 index 0000000..666fb1f --- /dev/null +++ b/test/sass/import-with-dot.scss @@ -0,0 +1 @@ +@import "file.with.dot"; diff --git a/tests/sass/import-yaml.scss b/test/sass/import-yaml.scss similarity index 100% rename from tests/sass/import-yaml.scss rename to test/sass/import-yaml.scss diff --git a/tests/sass/imported-css.css b/test/sass/imported-css.css similarity index 100% rename from tests/sass/imported-css.css rename to test/sass/imported-css.css