forked from postcss/postcss-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolve.js
74 lines (63 loc) · 1.57 KB
/
resolve.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
"use strict"
// external tooling
const test = require("ava")
// internal tooling
const checkFixture = require("./helpers/check-fixture")
test("should resolve relative to cwd", checkFixture, "resolve-cwd", {
path: null,
})
test(`should resolve relative to 'root' option`, checkFixture, "resolve-root", {
root: "test/fixtures",
path: null,
})
test(
`should resolve relative to postcss 'from' option`,
checkFixture,
"resolve-from",
{ path: null },
{ from: "test/fixtures/file.css" }
)
test(
`should resolve relative to 'path' which resolved with cwd`,
checkFixture,
"resolve-path-cwd",
{ path: "test/fixtures/imports" }
)
test(
`should resolve relative to 'path' which resolved with 'root'`,
checkFixture,
"resolve-path-root",
{ root: "test/fixtures", path: "imports" }
)
test("should resolve local modules", checkFixture, "resolve-local-modules", {
path: null,
})
test(
"should resolve modules with path option",
checkFixture,
"resolve-path-modules",
{
path: "test/fixtures/imports/modules",
}
)
test(
"should be able to consume npm package or local modules",
checkFixture,
"resolve-modules",
{ path: null },
{ from: "test/fixtures/imports/foo.css" }
)
test(
"should be able to consume npm sub packages",
checkFixture,
"resolve-npm-subpackages",
{ path: null },
{ from: "test/fixtures/imports/foo.css" }
)
test(
"should be able to consume modules from custom modules directories",
checkFixture,
"resolve-custom-modules",
{ path: null, addModulesDirectories: ["shared_modules"] },
{ from: "test/fixtures/imports/foo.css" }
)