mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 16:19:24 -07:00
Fix YouTube test yt-dlp fakes for non-Windows CI
This commit is contained in:
@@ -16,8 +16,14 @@ async function withTempDir<T>(fn: (dir: string) => Promise<T>): Promise<T> {
|
||||
|
||||
function makeFakeYtDlpScript(dir: string, payload: string): void {
|
||||
const scriptPath = path.join(dir, 'yt-dlp');
|
||||
const script = `#!/usr/bin/env node
|
||||
const script = process.platform === 'win32'
|
||||
? `#!/usr/bin/env node
|
||||
process.stdout.write(${JSON.stringify(payload)});
|
||||
`
|
||||
: `#!/usr/bin/env sh
|
||||
cat <<'EOF' | base64 -d
|
||||
${Buffer.from(payload).toString('base64')}
|
||||
EOF
|
||||
`;
|
||||
fs.writeFileSync(scriptPath, script, 'utf8');
|
||||
if (process.platform !== 'win32') {
|
||||
@@ -28,8 +34,10 @@ process.stdout.write(${JSON.stringify(payload)});
|
||||
|
||||
function makeHangingFakeYtDlpScript(dir: string): void {
|
||||
const scriptPath = path.join(dir, 'yt-dlp');
|
||||
const script = `#!/usr/bin/env node
|
||||
setInterval(() => {}, 1000);
|
||||
const script = `#!/usr/bin/env sh
|
||||
while :; do
|
||||
sleep 1;
|
||||
done
|
||||
`;
|
||||
fs.writeFileSync(scriptPath, script, 'utf8');
|
||||
if (process.platform !== 'win32') {
|
||||
|
||||
Reference in New Issue
Block a user