forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace require_context.js with babel-plugin-require-context-hook
- Loading branch information
Showing
13 changed files
with
33 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
addons/storyshots/storyshots-core/src/frameworks/config-loader.js
This file was deleted.
Oops, something went wrong.
25 changes: 15 additions & 10 deletions
25
addons/storyshots/storyshots-core/src/frameworks/configure.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
import loadConfig from './config-loader'; | ||
import runWithRequireContext from './require_context'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
function getConfigPathParts(configPath) { | ||
const resolvedConfigPath = path.resolve(configPath); | ||
|
||
if (fs.lstatSync(resolvedConfigPath).isDirectory()) { | ||
return path.join(resolvedConfigPath, 'config.js'); | ||
} | ||
|
||
return resolvedConfigPath; | ||
} | ||
|
||
function configure(options) { | ||
const { configPath = '.storybook', config, frameworkOptions, storybook } = options; | ||
const { configPath = '.storybook', config, storybook } = options; | ||
|
||
if (config && typeof config === 'function') { | ||
config(storybook); | ||
return; | ||
} | ||
|
||
const appOptions = require.requireActual(frameworkOptions).default; | ||
|
||
const { content, contextOpts } = loadConfig({ | ||
configPath, | ||
appOptions, | ||
}); | ||
const resolvedConfigPath = getConfigPathParts(configPath); | ||
|
||
runWithRequireContext(content, contextOpts); | ||
require.requireActual(resolvedConfigPath); | ||
} | ||
|
||
export default configure; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
addons/storyshots/storyshots-core/src/frameworks/require_context.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
], | ||
"env": { | ||
"test": { | ||
"presets": ["env"] | ||
"presets": ["env"], | ||
"plugins": ["require-context-hook"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters