Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
Sourcemap annotations should be string, not boolean, values
Browse files Browse the repository at this point in the history
- See postcss/autoprefixer docs:
  https://github.com/postcss/autoprefixer/blob/master/README.md#source-map

- Adds test to assert a string annotation is handled correctly
  • Loading branch information
Steffan Harries committed Mar 30, 2015
1 parent 27c2b31 commit 4ea7249
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ module.exports = function(grunt) {
src: 'test/fixtures/sm_inline_update.css',
dest: 'tmp/sm_inline_update.css'
},
sm_annotation_path: {
options: {
map: {
inline: false,
annotation: 'sm_updated_annotation.css.map'
}
},
src: 'test/fixtures/sm_annotation_path.css',
dest: 'tmp/sm_annotation_path.css'
},
log: {
src: 'tmp/single_file.css',
dest: 'tmp/single_file.css'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ You can gain more control over sourcemap generation by setting an object to the

* `prev` (string or `false`): a path to a directory where a previous sourcemap is (e.g. `path/`). By default, Autoprefixer will try to find a previous sourcemap using a path from the annotation comment (or using the annotation comment itself if the map is inlined). You can also set this option to `false` to delete the previous sourcemap.
* `inline` (boolean): whether a sourcemap will be inlined or not. By default, it will be the same as a previous sourcemap or inlined.
* `annotation` (boolean or string): set this option to `true` or `false` to enable or disable annotation comments. You can also overwrite an output sourcemap path using this option, e.g. `path/file.css.map` (by default, Autoprefixer will save your sourcemap to a directory where you save CSS). This option requires `inline` to be `false` or undefined.
* `annotation` (string): set this option to URL path you wish the annotation comment to be e.g. `path/file.css.map` (by default, Autoprefixer will save your sourcemap to a directory where you save CSS). This option requires `inline` to be `false` or undefined.
* `sourcesContent` (boolean): whether original contents (e.g. Sass sources) will be included to a sourcemap. By default, Autoprefixer will add contents only for new sourcemaps or if a previous sourcemap has them.

#### options.silent
Expand Down
2 changes: 1 addition & 1 deletion tasks/autoprefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function(grunt) {
map: (typeof options.map === 'boolean') ? options.map : {
prev: getPrevMap(from),
inline: (typeof options.map.inline === 'boolean') ? options.map.inline : true,
annotation: (typeof options.map.annotation === 'boolean') ? options.map.annotation : true,
annotation: (typeof options.map.annotation === 'string') ? options.map.annotation : true,
sourcesContent: (typeof options.map.sourcesContent === 'boolean') ? options.map.sourcesContent : true
},
from: from,
Expand Down
13 changes: 13 additions & 0 deletions test/expected/sm_annotation_path.css

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

13 changes: 13 additions & 0 deletions test/fixtures/sm_annotation_path.css

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

8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,13 @@ exports.autoprefixer = {

test.strictEqual(actual, expected, 'should update an inlined source map.');
test.done();
},

sm_annotation_path: function(test) {
var actual = grunt.file.read('tmp/sm_annotation_path.css');
var expected = grunt.file.read('test/expected/sm_annotation_path.css');

test.strictEqual(actual, expected, 'should update sourcemap annotation.');
test.done();
}
};

0 comments on commit 4ea7249

Please sign in to comment.