Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ripe-carrots-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-docgen/cli': patch
---

Remove slash dependency
3 changes: 1 addition & 2 deletions packages/react-docgen-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"commander": "15.0.0",
"debug": "4.4.3",
"fast-glob": "3.3.3",
"react-docgen": "workspace:8.0.3",
"slash": "5.1.0"
"react-docgen": "workspace:8.0.3"
},
"devDependencies": {
"@types/debug": "4.1.13"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-docgen-cli/src/commands/parse/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import outputResult from './output/outputResult.js';
import loadOptions from './options/loadOptions.js';
import outputError from './output/outputError.js';
import { resolve } from 'path';
import slash from 'slash';
import slash from '../../utils/slash.js';
import type { Documentation } from 'react-docgen';
import { ResolverConfigs } from './options/loadResolvers.js';

Expand Down
22 changes: 22 additions & 0 deletions packages/react-docgen-cli/src/utils/__tests__/slash-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Based on npm slash package: https://www.npmjs.com/package/slash
Licensed under MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
*/

import { describe, expect, test } from 'vitest';
import slash from '../slash';

describe('slash', () => {
test('convert backwards-slash paths to forward slash paths', () => {
expect(slash('c:/aaaa\\bbbb')).toBe('c:/aaaa/bbbb');
expect(slash('c:\\aaaa\\bbbb')).toBe('c:/aaaa/bbbb');
expect(slash('c:\\aaaa\\bbbb\\★')).toBe('c:/aaaa/bbbb/★');
});

test('not convert extended-length paths', () => {
const path = '\\\\?\\c:\\aaaa\\bbbb';

expect(slash(path)).toBe(path);
});
});
15 changes: 15 additions & 0 deletions packages/react-docgen-cli/src/utils/slash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Based on npm slash package: https://www.npmjs.com/package/slash
Licensed under MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
*/

export default function slash(path: string): string {
const isExtendedLengthPath = path.startsWith('\\\\?\\');

if (isExtendedLengthPath) {
return path;
}

return path.replace(/\\/g, '/');
}
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading