storybook/addons/storyshots/src/hasDependency.js
2017-12-26 17:41:05 +02:00

14 lines
360 B
JavaScript

import fs from 'fs';
import path from 'path';
import readPkgUp from 'read-pkg-up';
const { pkg } = readPkgUp.sync();
export default function hasDependency(name) {
return (
(pkg.devDependencies && pkg.devDependencies[name]) ||
(pkg.dependencies && pkg.dependencies[name]) ||
fs.existsSync(path.join('node_modules', name, 'package.json'))
);
}