(
root: string,
contents = 'process.stdout.write(JSON.stringify({args:process.argv.slice(2)}));\n',
options: { writeProjectRoot?: boolean } = {}
)
| 74 | } |
| 75 | |
| 76 | function 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 | |
| 106 | const windowsOnlyTest = process.platform === 'win32' ? test : test.skip; |
| 107 | const posixOnlyTest = process.platform === 'win32' ? test.skip : test; |
no test coverage detected