Skip to content

Commit

Permalink
fix(build): make storybook stories generation script runnable on wind…
Browse files Browse the repository at this point in the history
…ows platform (#606)

Co-authored-by: yinon <yinon@hotmail.com>
  • Loading branch information
k-paxian and yinonov committed Jan 25, 2021
1 parent ba05559 commit ba93066
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .storybook/build-scripts/create-stories-from-md.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export {
const CONFIGS_LOOKUP_PATTERN = '+(common|components|docs)/**/stories/**/*.config.+(js|mjs)';
const DEFAULT_OUTPUT_FILE_SUFFIX = '.autogenerated.stories.js';

const filePath2fileUrl = filePath => {
let pathName = resolve(filePath).replace(/\\/g, '/');

// Windows drive letter must be prefixed with a slash
if (pathName[0] !== '/') {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
};
const FS_OPTIONS = { encoding: 'utf-8' };
const converter = new showdown.Converter();
converter.setFlavor('github');
Expand All @@ -38,7 +48,7 @@ function collectConfigurations() {
async function processJsConfiguration(configPath) {
console.info(`processing '${configPath}'...`);

const config = (await import(resolve(configPath))).default;
const config = (await import(filePath2fileUrl(configPath))).default;
validateConfig(config);

// convert
Expand Down

0 comments on commit ba93066

Please sign in to comment.