Last active
January 12, 2025 08:49
-
-
Save gavvvr/d9b60ccf306db1fa9d327b1c495055fa to your computer and use it in GitHub Desktop.
Download source codes of all obsidian community plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https') | |
const { spawn } = require('child_process') | |
const url = | |
'https://raw.githubusercontent.com/obsidianmd/obsidian-releases/master/community-plugins.json' | |
https.get(url, (res) => { | |
let data = [] | |
res.on('data', (chunk) => { | |
data.push(chunk) | |
}) | |
res.on('end', async () => { | |
const plugins = JSON.parse(Buffer.concat(data).toString()) | |
for (const plugin of plugins) { | |
const repoUrl = `https://github.com/${plugin.repo}` | |
await cloneRepository(repoUrl); | |
} | |
}) | |
}) | |
function cloneRepository(repoUrl) { | |
return new Promise((resolve, reject) => { | |
console.log(`Cloning ${repoUrl}...`); | |
const gitProcess = spawn('git', ['clone', repoUrl], { stdio: 'inherit' }); | |
gitProcess.on('close', (code) => { | |
if (code === 0) { | |
console.log(`Successfully cloned: ${repoUrl}`); | |
resolve(); | |
} else { | |
console.error(`Failed to clone: ${repoUrl} (exit code: ${code})`); | |
reject(new Error(`Git process exited with code ${code}`)); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment