UNPKG

react-cosmos

Version:

CLI for running React Cosmos inside webpack-powered apps

45 lines (36 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getUserModules = getUserModules; var _path = _interopRequireDefault(require("path")); var _slash = _interopRequireDefault(require("slash")); var _findUserModulePaths2 = require("./findUserModulePaths"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function getUserModules(_ref) { var rootDir = _ref.rootDir, fixturesDir = _ref.fixturesDir, fixtureFileSuffix = _ref.fixtureFileSuffix; var _findUserModulePaths = (0, _findUserModulePaths2.findUserModulePaths)({ rootDir: rootDir, fixturesDir: fixturesDir, fixtureFileSuffix: fixtureFileSuffix }), fixturePaths = _findUserModulePaths.fixturePaths, decoratorPaths = _findUserModulePaths.decoratorPaths; return { fixtures: getDefaultExports(fixturePaths, rootDir), decorators: getDefaultExports(decoratorPaths, rootDir) }; } function getDefaultExports(paths, rootDir) { var exportsByPath = {}; paths.forEach(function (p) { // Converting to forward slashes on Windows is important because the // slashes are used for generating a sorted list of fixtures and // decorators. var relPath = (0, _slash.default)(_path.default.relative(rootDir, p)); exportsByPath[relPath] = require(p).default; }); return exportsByPath; }