-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathmap.js
78 lines (63 loc) · 1.59 KB
/
map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import test from 'ava'
import fs from 'fs-extra'
import cli from './helpers/cli.js'
import tmp from './helpers/tmp.js'
import read from './helpers/read.js'
import getMapfile from '../lib/getMapfile'
test('inline maps are generated by default', async t => {
const output = tmp('output.css')
const { error, stderr } = await cli([
'test/fixtures/import.css',
'-u',
'postcss-import',
'-o',
output
])
t.falsy(error, stderr)
t.regex(await read(output), /\/*# sourceMappingURL=/)
})
test('--map generates external sourcemaps', async t => {
const output = tmp('output.css')
const { error, stderr } = await cli([
'test/fixtures/import.css',
'-u',
'postcss-import',
'-o',
output,
'--map'
])
t.falsy(error, stderr)
t.truthy(await fs.pathExists(output.replace('.css', '.css.map')))
})
test('--no-map disables internal sourcemaps', async t => {
const output = tmp('output.css')
const { error, stderr } = await cli([
'test/fixtures/import.css',
'-u',
'postcss-import',
'-o',
output,
'--no-map'
])
t.falsy(error, stderr)
t.notRegex(await read(output), /\/*# sourceMappingURL=/)
})
test('mapFile path is property resolved', async t => {
const paths = [
{
input: '/foo/bar.css/baz/index.css',
want: '/foo/bar.css/baz/index.css.map'
},
{
input: '/foo/bar.sss/baz/index.sss',
want: '/foo/bar.sss/baz/index.sss.map'
},
{
input: '/foo/bar.css/baz/bar.css',
want: '/foo/bar.css/baz/bar.css.map'
}
]
for (const p of paths) {
t.is(getMapfile(p.input), p.want)
}
})