MCPcopy Create free account
hub / github.com/vercel/vercel / writeLocalVercelPackage

Function writeLocalVercelPackage

packages/cli-exec/tests/index.test.ts:76–104  ·  view source on GitHub ↗
(
  root: string,
  contents = 'process.stdout.write(JSON.stringify({args:process.argv.slice(2)}));\n',
  options: { writeProjectRoot?: boolean } = {}
)

Source from the content-addressed store, hash-verified

74}
75
76function writeLocalVercelPackage(
77 root: string,
78 contents = 'process.stdout.write(JSON.stringify({args:process.argv.slice(2)}));\n',
79 options: { writeProjectRoot?: boolean } = {}
80): { binPath: string; cliPath: string } {
81 const binPath = path.join(root, 'node_modules', '.bin', getVercelBinName());
82 const packageDirectory = path.join(root, 'node_modules', 'vercel');
83 const cliPath = path.join(packageDirectory, 'dist', 'vc.js');
84
85 if (options.writeProjectRoot !== false) {
86 writeProjectRoot(root);
87 }
88 mkdirSync(path.dirname(binPath), { recursive: true });
89 mkdirSync(path.dirname(cliPath), { recursive: true });
90 writeFileSync(
91 path.join(packageDirectory, 'package.json'),
92 JSON.stringify({ name: 'vercel', bin: { vercel: './dist/vc.js' } })
93 );
94 writeFileSync(cliPath, contents);
95
96 if (process.platform === 'win32') {
97 writeFileSync(binPath, '@echo off\r\n');
98 } else {
99 chmodSync(cliPath, 0o755);
100 symlinkSync(cliPath, binPath);
101 }
102
103 return { binPath, cliPath };
104}
105
106const windowsOnlyTest = process.platform === 'win32' ? test : test.skip;
107const posixOnlyTest = process.platform === 'win32' ? test.skip : test;

Callers 1

index.test.tsFile · 0.85

Calls 3

getVercelBinNameFunction · 0.85
writeProjectRootFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected