1
1
mirror of https://github.com/primer/css.git synced 2024-11-23 20:38:58 +03:00

fix warning about root

This commit is contained in:
Shawn Allen 2018-12-07 11:29:17 -08:00
parent b183d91cbc
commit c371303a8a

View File

@ -8,8 +8,7 @@ module.exports = function addPackageMeta(options = {}) {
return (files, metal, done) => { return (files, metal, done) => {
const root = metal.source() const root = metal.source()
for (const [path, file] of Object.entries(files)) { for (const [path, file] of Object.entries(files)) {
const fullPath = join(root, path) const pkg = getPackageRelativeTo(path, root)
const pkg = getPackageRelativeTo(dirname(fullPath))
if (pkg) { if (pkg) {
file[namespace].package = fields ? pluck(pkg, fields) : pkg file[namespace].package = fields ? pluck(pkg, fields) : pkg
} else { } else {
@ -20,7 +19,8 @@ module.exports = function addPackageMeta(options = {}) {
} }
} }
function getPackageRelativeTo(dir) { function getPackageRelativeTo(file, root) {
let dir = join(root, dirname(file))
if (dir in cache) { if (dir in cache) {
return cache[dir] return cache[dir]
} }