MCPcopy Create free account
hub / github.com/ShipSecAI/studio / collectCandidatePaths

Function collectCandidatePaths

pm2.config.cjs:106–145  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

104}
105
106function collectCandidatePaths(target) {
107 const candidates = [];
108 const bunDir = path.join(__dirname, 'node_modules', '.bun');
109 const aggregateDir = path.join(bunDir, 'node_modules', '@swc', `core-${target}`, `swc.${target}.node`);
110
111 if (aggregateDir && fs.existsSync(aggregateDir)) {
112 candidates.push(aggregateDir);
113 }
114
115 try {
116 const entries = fs.readdirSync(bunDir);
117 for (const entry of entries) {
118 if (entry.startsWith(`@swc+core-${target}@`)) {
119 const versionedPath = path.join(
120 bunDir,
121 entry,
122 'node_modules',
123 '@swc',
124 `core-${target}`,
125 `swc.${target}.node`,
126 );
127 candidates.push(versionedPath);
128 }
129 }
130 } catch (_) {
131 // Unable to scan versioned directories; continue with resolver fallback.
132 }
133
134 try {
135 const resolvedPkg = require.resolve(`@swc/core-${target}/package.json`, {
136 paths: [path.join(bunDir, 'node_modules'), __dirname],
137 });
138 const resolvedCandidate = path.join(path.dirname(resolvedPkg), `swc.${target}.node`);
139 candidates.push(resolvedCandidate);
140 } catch (_) {
141 // Optional dependency may not be installed for this platform.
142 }
143
144 return Array.from(new Set(candidates));
145}
146
147function resolveSwcBinaryPath() {
148 const targets = getSwcTargets();

Callers 1

resolveSwcBinaryPathFunction · 0.85

Calls 3

fromMethod · 0.80
pushMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected