MCPcopy Index your code
hub / github.com/devcontainers/cli / convertMountToVolume

Function convertMountToVolume

src/spec-node/singleContainer.ts:454–469  ·  view source on GitHub ↗
(mountStr: string)

Source from the content-addressed store, hash-verified

452
453// Convert a --mount string (e.g., "type=bind,source=/a,target=/b,consistency=cached") to -v syntax for wslc.
454function convertMountToVolume(mountStr: string): string[] {
455 const parts = new Map(mountStr.split(',').map(p => {
456 const eq = p.indexOf('=');
457 return eq === -1 ? [p, ''] : [p.substring(0, eq), p.substring(eq + 1)];
458 }));
459 const source = parts.get('source') || parts.get('src') || '';
460 const target = parts.get('target') || parts.get('dst') || parts.get('destination') || '';
461 if (source && target) {
462 return ['-v', `${source}:${target}`];
463 }
464 if (target) {
465 return ['-v', target];
466 }
467 // Fallback: pass as --mount and let the runtime handle it.
468 return ['--mount', mountStr];
469}
470
471// Convert --mount args array (e.g., ['--mount', 'type=bind,...']) to -v syntax for wslc.
472function convertMountArgsToVolume(args: string[]): string[] {

Callers 2

spawnDevContainerFunction · 0.70
convertMountArgsToVolumeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected