Created
May 15, 2023 16:58
-
-
Save MaddyGuthridge/c7805abfb46776db7f073869cf241e21 to your computer and use it in GitHub Desktop.
npm install *
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 { execSync } = require('node:child_process'); | |
const MAX_LENGTH = 100; | |
// https://stackoverflow.com/a/44574128/6335363 | |
const ALLOWED_CHARACTERS = [...Array(26).keys()].map((n) => String.fromCharCode(97 + n)); | |
ALLOWED_CHARACTERS.push('-'); | |
function installPackage(name) { | |
execSync(`npm install ${name}`, { stdio: 'inherit' }); | |
} | |
function generateCombinations(prev, depth) { | |
if (depth === 0) { | |
installPackage(prev); | |
} else { | |
for (const c of ALLOWED_CHARACTERS) { | |
generateCombinations(prev + c, depth - 1); | |
} | |
} | |
} | |
for (let i = 1; i < MAX_LENGTH; i++) { | |
generateCombinations('', i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment