Skip to content

Instantly share code, notes, and snippets.

@MaddyGuthridge
Created May 15, 2023 16:58
Show Gist options
  • Save MaddyGuthridge/c7805abfb46776db7f073869cf241e21 to your computer and use it in GitHub Desktop.
Save MaddyGuthridge/c7805abfb46776db7f073869cf241e21 to your computer and use it in GitHub Desktop.
npm install *
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