import { execSync } from 'child_process'; import { findImports } from './find-imports.js'; import { getModules } from './get-modules.js'; function getGitDiff(options) { const TARGET_BRANCH = options[2] || 'dev'; const diff = execSync(`git diff --name-only origin/${TARGET_BRANCH}`, { encoding: 'utf-8', }); return diff.split('\n'); } async function getChangedModules() { let changedModules = new Set(); const changes = getGitDiff(process.argv); for (const change of changes) { changedModules = new Set([ ...changedModules, ...new Set(getModules(await findImports(change))), ]); } return [...changedModules].join(','); } getChangedModules() .then((modules) => console.log(modules)) // return .catch(() => { process.exit(1); });