source: trip-planner-front/node_modules/postcss-import/lib/resolve-id.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1"use strict"
2
3// external tooling
4const resolve = require("resolve")
5
6const moduleDirectories = ["web_modules", "node_modules"]
7
8function resolveModule(id, opts) {
9 return new Promise((res, rej) => {
10 resolve(id, opts, (err, path) => (err ? rej(err) : res(path)))
11 })
12}
13
14module.exports = function (id, base, options) {
15 const paths = options.path
16
17 const resolveOpts = {
18 basedir: base,
19 moduleDirectory: moduleDirectories.concat(options.addModulesDirectories),
20 paths,
21 extensions: [".css"],
22 packageFilter: function processPackage(pkg) {
23 if (pkg.style) pkg.main = pkg.style
24 else if (!pkg.main || !/\.css$/.test(pkg.main)) pkg.main = "index.css"
25 return pkg
26 },
27 preserveSymlinks: false,
28 }
29
30 return resolveModule(`./${id}`, resolveOpts)
31 .catch(() => resolveModule(id, resolveOpts))
32 .catch(() => {
33 if (paths.indexOf(base) === -1) paths.unshift(base)
34
35 throw new Error(
36 `Failed to find '${id}'
37 in [
38 ${paths.join(",\n ")}
39 ]`
40 )
41 })
42}
Note: See TracBrowser for help on using the repository browser.