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

Function setup

esbuild.js:20–58  ·  view source on GitHub ↗
(build)

Source from the content-addressed store, hash-verified

18 const plugin = {
19 name: 'patch up',
20 setup(build) {
21 build.onLoad({ filter: /node_modules[\/\\]yargs[\/\\]lib[\/\\]platform-shims[\/\\]esm\.mjs$/ }, async (args) => {
22 let text = await fs.promises.readFile(args.path, 'utf8');
23 let fileUri = uri.URI.file(args.path);
24 fileUri = fileUri.with({
25 path: path.posix.join('/C:', fileUri.path)
26 });
27 return {
28 contents: text.replace(/import\.meta\.url/g, `'${fileUri.toString()}'`),
29 loader: 'js',
30 };
31 });
32 build.onLoad({ filter: /node_modules[\/\\]vm2[\/\\]lib[\/\\]vm.js$/ }, async (args) => {
33 const text = await fs.promises.readFile(args.path, 'utf8');
34 const regex = /fs\.readFileSync\(`\$\{__dirname\}\/([^`]+)`, 'utf8'\)/g;
35 const files = await [...new Set(text.matchAll(regex))]
36 .reduce(async (prevP, m) => {
37 const text = (await fs.promises.readFile(path.join(path.dirname(args.path), m[1]), 'utf8'));
38 const prev = await prevP;
39 prev[m[1]] = text;
40 return prev;
41 }, Promise.resolve({}));
42 const contents = text.replace(regex, (_sub, file) => {
43 return `\`${files[file].replace(/[`$]/g, '\\$&')}\``;
44 });
45 return {
46 contents,
47 loader: 'js',
48 };
49 });
50 // Work around https://github.com/TooTallNate/node-pac-proxy-agent/issues/21.
51 build.onLoad({ filter: /node_modules[\/\\]ftp[\/\\]lib[\/\\]connection.js$/ }, async (args) => {
52 const text = await fs.promises.readFile(args.path, 'utf8');
53 return {
54 contents: text.replace(/\bnew Buffer\(/g, 'Buffer.from('),
55 loader: 'js',
56 };
57 });
58 },
59 };
60
61 /** @type {import('esbuild').BuildOptions} */

Callers

nothing calls this directly

Calls 1

readFileMethod · 0.65

Tested by

no test coverage detected