File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const reporter = require('postcss-reporter/lib/formatter')()
1616
1717const argv = require ( './lib/args' )
1818const depGraph = require ( './lib/depGraph' )
19+ const getMapfile = require ( './lib/getMapfile' )
1920
2021let input = argv . _
2122const { dir, output } = argv
@@ -221,10 +222,7 @@ function css(css, file) {
221222 tasks . push ( fs . outputFile ( options . to , result . css ) )
222223
223224 if ( result . map ) {
224- const mapfile = options . to . replace (
225- path . extname ( options . to ) ,
226- `${ path . extname ( options . to ) } .map`
227- )
225+ const mapfile = getMapfile ( options . to )
228226 tasks . push ( fs . outputFile ( mapfile , result . map ) )
229227 }
230228 } else process . stdout . write ( result . css , 'utf8' )
Original file line number Diff line number Diff line change 1+ 'use strict'
2+ module . exports = function getMapfile ( p ) {
3+ return `${ p } .map`
4+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import cli from './helpers/cli.js'
55import tmp from './helpers/tmp.js'
66import read from './helpers/read.js'
77
8+ import getMapfile from '../lib/getMapfile'
9+
810test ( 'inline maps are generated by default' , async t => {
911 const output = tmp ( 'output.css' )
1012
@@ -53,3 +55,24 @@ test('--no-map disables internal sourcemaps', async t => {
5355
5456 t . notRegex ( await read ( output ) , / \/ * # s o u r c e M a p p i n g U R L = / )
5557} )
58+
59+ test ( 'mapFile path is property resolved' , async t => {
60+ const paths = [
61+ {
62+ input : '/foo/bar.css/baz/index.css' ,
63+ want : '/foo/bar.css/baz/index.css.map'
64+ } ,
65+ {
66+ input : '/foo/bar.sss/baz/index.sss' ,
67+ want : '/foo/bar.sss/baz/index.sss.map'
68+ } ,
69+ {
70+ input : '/foo/bar.css/baz/bar.css' ,
71+ want : '/foo/bar.css/baz/bar.css.map'
72+ }
73+ ]
74+
75+ for ( const p of paths ) {
76+ t . is ( getMapfile ( p . input ) , p . want )
77+ }
78+ } )
You can’t perform that action at this time.
0 commit comments