Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix absolute paths #203

Merged
merged 1 commit into from
Apr 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
'use strict';
var path = require('path');
function absolutePath(file) {
return path.join(__dirname, file);
}
module.exports = function (grunt) {
grunt.initConfig({
jshint: {
Expand All @@ -18,6 +22,15 @@ module.exports = function (grunt) {
options: {
sourceMap: true
},
absolute: {
files: [{
src: [
'test/fixtures/input_one.css',
'test/fixtures/input_two.css'
].map(absolutePath),
dest: absolutePath('tmp/absolute.css')
}]
},
compress: {
files: {
'tmp/style.css': [
Expand Down
1 change: 1 addition & 0 deletions tasks/cssmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = function (grunt) {
var compiled = '';

options.target = file.dest;
options.relativeTo = path.dirname(availableFiles[0]);

try {
compiled = new CleanCSS(options).minify(availableFiles);
Expand Down
2 changes: 2 additions & 0 deletions test/expected/absolute.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ exports.cssmin = {
var result = grunt.file.read('tmp/inline_import.css').replace(/\r\n/g,'').replace(/\n/g,'');
test.equal(expect, result, 'should inline @import');

test.done();
},
absolute: function(test) {
test.expect(1);

var expect = grunt.file.read('test/expected/absolute.css').replace(/\r\n/g,'').replace(/\n/g,'');
var result = grunt.file.read('tmp/absolute.css').replace(/\r\n/g,'').replace(/\n/g,'');
test.equal(expect, result, 'should perform the standard tasks when given absolute paths');

test.done();
}
};