INNER CODE UNIT · JavaScript
downloadToFile
geekjourneyx/md2wechat-skill · scripts/install.js:66
function downloadToFile(source, destinationPath) {
if (!hasScheme(source)) {
fs.copyFileSync(source, destinationPath);
return Promise.resolve();
}
if (source.startsWith("file://")) {
fs.copyFileSync(fileURLToPath(source), destinationPath);
return Promise.resolve();
}
return new Promise((resolve, reject) => {
const client = source.startsWith("https:") ? https : http;
client
.get(source, (response) => {
if (
(response.statusCode === 301 || response.statusCode === 302) &&