Skip to content

Commit

Permalink
use non-ESM-only version of slash
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvebn committed Aug 6, 2021
1 parent f789cef commit 8647675
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/core-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"lodash": "^4.17.20",
"qs": "^6.10.0",
"regenerator-runtime": "^0.13.7",
"slash": "^4.0.0",
"slash": "^3.0.0",
"ts-dedent": "^2.0.0",
"unfetch": "^4.2.0",
"util-deprecate": "^1.0.2"
Expand Down
4 changes: 2 additions & 2 deletions lib/core-client/src/preview/autoTitle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('autoTitle', () => {

it('match with windows path', () => {
expect(
auto('/path/to_my/file', { glob: '', specifier: { directory: '.\\path' } })
auto('/path/to_my/file', { glob: '', specifier: { directory: '\\path' } })
).toMatchInlineSnapshot(`To My/File`);
});
});
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('autoTitle', () => {

it('match with windows path', () => {
expect(
auto('/path/to_my/file', { glob: '', specifier: { directory: '.\\path\\' } })
auto('/path/to_my/file', { glob: '', specifier: { directory: '\\path\\' } })
).toMatchInlineSnapshot(`To My/File`);
});
});
Expand Down
5 changes: 3 additions & 2 deletions lib/core-client/src/preview/autoTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ export const autoTitleFromEntry = (fileName: string, entry: NormalizedStoriesEnt
const { directory, titlePrefix = '' } = entry.specifier || {};
// On Windows, backslashes are used in paths, which can cause problems here
// slash makes sure we always handle paths with unix-style forward slash
const normalizedDirectory = slash(directory);
const normalizedDirectory = directory && slash(directory);
const normalizedFileName = slash(fileName);

if (normalizedFileName.startsWith(normalizedDirectory)) {
const suffix = normalizedFileName.replace(normalizedDirectory, '');
return startCaseTitle(stripExtension(path.join(titlePrefix, suffix)));
const titleAndSuffix = slash(path.join(titlePrefix, suffix));
return startCaseTitle(stripExtension(titleAndSuffix));
}
return undefined;
};
Expand Down
3 changes: 1 addition & 2 deletions lib/core-common/src/utils/es6Transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ const nodeModulesThatNeedToBeParsedBecauseTheyExposeES6 = [
'node_modules/highlight.js',
'node_modules/json5',
'node_modules/semver',
'node_modules/slash',
];

export const es6Transpiler: () => RuleSetRule = () => {
// TODO: generate regexp using are-you-es5

console.log('es6Transpiler');
const include = (input: string) => {
return (
!!nodeModulesThatNeedToBeParsedBecauseTheyExposeES6.find((p) => input.includes(p)) ||
Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6897,7 +6897,7 @@ __metadata:
lodash: ^4.17.20
qs: ^6.10.0
regenerator-runtime: ^0.13.7
slash: ^4.0.0
slash: ^3.0.0
ts-dedent: ^2.0.0
unfetch: ^4.2.0
util-deprecate: ^1.0.2
Expand Down Expand Up @@ -39038,13 +39038,6 @@ [email protected]:
languageName: node
linkType: hard

"slash@npm:^4.0.0":
version: 4.0.0
resolution: "slash@npm:4.0.0"
checksum: b522ca75d80d107fd30d29df0549a7b2537c83c4c4ecd12cd7d4ea6c8aaca2ab17ada002e7a1d78a9d736a0261509f26ea5b489082ee443a3a810586ef8eff18
languageName: node
linkType: hard

"slice-ansi@npm:0.0.4":
version: 0.0.4
resolution: "slice-ansi@npm:0.0.4"
Expand Down

0 comments on commit 8647675

Please sign in to comment.