{"version":3,"file":"filter_project_info.js","sourceRoot":"","sources":["../../src/commands/filter_project_info.ts"],"names":[],"mappings":";;;;;AASA,0DA2BC;AApCD,4CAAmB;AACnB,gDAAuB;AAEvB,+CAAiD;AAEjD;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,WAAwB,EACxB,IAAwB;IAExB,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAElC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,IAAA,uBAAa,EAAC,mBAAmB,OAAO,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAA;IAE9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,IAAA,uBAAa,EACX,QAAQ,OAAO,6CAA6C;YAC1D,gEAAgE,CACnE,CAAA;IACH,CAAC;IAED,OAAO;QACL,GAAG,WAAW;QACd,KAAK,EAAE,OAAO;KACf,CAAA;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport { ProjectInfo } from '../connect/project'\nimport { exitWithError } from '../common/logging'\n\n/**\n * If --file is specified, filter projectInfo.files to only include that file.\n * Exits with an error if the file doesn't exist or isn't in the project's file list.\n */\nexport function filterProjectInfoByFile(\n projectInfo: ProjectInfo,\n file: string | undefined,\n): ProjectInfo {\n if (!file) {\n return projectInfo\n }\n\n const absFile = path.resolve(file)\n\n if (!fs.existsSync(absFile)) {\n exitWithError(`File not found: ${absFile}`)\n }\n\n const matched = projectInfo.files.filter((f) => f === absFile)\n\n if (matched.length === 0) {\n exitWithError(\n `File ${absFile} was not found in the project's file list. ` +\n `Make sure it matches the include/exclude globs in your config.`,\n )\n }\n\n return {\n ...projectInfo,\n files: matched,\n }\n}\n"]}