in github-release-binary.js [100:163]
async fetchFromNetwork(locator, opts) {
// 1980-01-01, like Fedora
const defaultTime = 315532800;
const parts = parse(locator.reference);
const releaseBuffer = await httpUtils.get(`https://github.com/${parts.organization}/${parts.repository}/releases/download/${parts.version}/${parts.binary}`, {
configuration: opts.project.configuration,
});
const packageName = ppath.join(locator.scope !== null ? '@' + locator.scope : '', locator.name);
const tmpDir = xfs.mktempSync();
const zipFS = new ZipFS(ppath.join(tmpDir, 'release.zip'), { create: true, libzip: await getLibzipPromise() });
zipFS.writeFileSync('package.json', `{ "name": "${packageName}", "dependencies": { "@yarnpkg/fslib": "${YARN_FS_VERSION}" } }`);
zipFS.utimesSync('package.json', defaultTime, defaultTime);
const dir = ppath.join('node_modules', packageName);
zipFS.mkdirSync(dir, { recursive: true });
const stubFile = ppath.join(dir, 'exec.js');
zipFS.writeFileSync(stubFile, `const { xfs } = require('@yarnpkg/fslib');
const fs = require('fs');
const path = require('path');
const os = require('os');
const { spawn } = require('child_process');
const execute = (path, args) => {
const child = spawn(path, args);
process.stdin.pipe(child.stdin);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on('error', err => { process.stderr.write(err + '\\n'); process.exit(1) } );
child.on('exit', status => process.exit(status));
}
(async () => {
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'github-release-binary'));
process.on('exit', () => {
fs.rmdirSync(tmpDir, { recursive: true });
})
const binary = process.argv[1].replace('exec.js', '${parts.binary}');
const binaryPath = path.join(tmpDir, '${parts.binary}');
await xfs.copyFilePromise(binary, binaryPath);
await xfs.chmodPromise(binaryPath, 0o755);
execute(binaryPath, process.argv.slice(2));
})();`);
zipFS.chmodSync(stubFile, 0o755);
zipFS.utimesSync(stubFile, defaultTime, defaultTime);
const binaryPath = ppath.join(dir, parts.binary);
zipFS.writeFileSync(binaryPath, releaseBuffer);
zipFS.chmodSync(binaryPath, 0o755);
zipFS.utimesSync(binaryPath, defaultTime, defaultTime);
xfs.detachTemp(tmpDir);
return zipFS;
}