@@ -16,8 +16,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
1616 });
1717};
1818Object.defineProperty(exports, "__esModule", ({ value: true }));
19- exports.execCommand = void 0;
19+ exports.setOutputs = exports.execCommand = void 0;
20+ const core_1 = __nccwpck_require__(5316);
2021const exec_1 = __nccwpck_require__(110);
22+ const serialization_utils_1 = __nccwpck_require__(9091);
2123function execCommand(command) {
2224 return __awaiter(this, void 0, void 0, function* () {
2325 const { stdout, stderr, exitCode } = yield (0, exec_1.getExecOutput)(command);
@@ -28,6 +30,12 @@ function execCommand(command) {
2830 });
2931}
3032exports.execCommand = execCommand;
33+ function setOutputs(values) {
34+ for (const [key, value] of Object.entries(values)) {
35+ (0, core_1.setOutput)(key, (0, serialization_utils_1.stringifyForShell)(value));
36+ }
37+ }
38+ exports.setOutputs = setOutputs;
3139
3240
3341/***/ }),
@@ -126,7 +134,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
126134 return result;
127135};
128136Object.defineProperty(exports, "__esModule", ({ value: true }));
129- exports.filterPaths = void 0;
137+ exports.testPath = exports. filterPaths = void 0;
130138const core = __importStar(__nccwpck_require__(5316));
131139const minimatch_1 = __nccwpck_require__(148);
132140const NEGATION = '!';
@@ -146,14 +154,16 @@ exports.filterPaths = filterPaths;
146154function filterPathsImpl(paths, patterns) {
147155 return (patterns === null || patterns === void 0 ? void 0 : patterns.length) === 0
148156 ? paths
149- : paths.filter(path => {
150- return patterns.reduce((prevResult, pattern) => {
151- return pattern.startsWith(NEGATION)
152- ? prevResult && !match(path, pattern.substring(1))
153- : prevResult || match(path, pattern);
154- }, false);
155- });
157+ : paths.filter(path => testPath(path, patterns));
158+ }
159+ function testPath(path, patterns) {
160+ return patterns.reduce((prevResult, pattern) => {
161+ return pattern.startsWith(NEGATION)
162+ ? prevResult && !match(path, pattern.substring(1))
163+ : prevResult || match(path, pattern);
164+ }, false);
156165}
166+ exports.testPath = testPath;
157167
158168
159169/***/ }),
@@ -251,12 +261,12 @@ function getChangedFilesImpl(token) {
251261 core.setFailed('Getting changed files only works on pull request events.');
252262 return [];
253263 }
254- const files = yield octokit.paginate(octokit.rest.pulls.listFiles, {
264+ const entries = yield octokit.paginate(octokit.rest.pulls.listFiles, {
255265 owner: github_1.context.repo.owner,
256266 repo: github_1.context.repo.repo,
257267 pull_number: github_1.context.payload.pull_request.number,
258268 });
259- return files .map(file => file. filename);
269+ return entries .map(({ filename, status }) => ({ path: filename, status }) );
260270 }
261271 catch (error) {
262272 core.setFailed(`Getting changed files failed with error: ${error}`);
@@ -266,6 +276,44 @@ function getChangedFilesImpl(token) {
266276}
267277
268278
279+ /***/ }),
280+
281+ /***/ 9091:
282+ /***/ ((__unused_webpack_module, exports) => {
283+
284+ "use strict";
285+
286+ Object.defineProperty(exports, "__esModule", ({ value: true }));
287+ exports.stringifyForShell = void 0;
288+ function stringifyArrayItem(item) {
289+ switch (typeof item) {
290+ case 'number':
291+ return item.toString();
292+ case 'string':
293+ return `'${item}'`;
294+ default:
295+ return JSON.stringify(item);
296+ }
297+ }
298+ function stringifyForShell(value) {
299+ switch (typeof value) {
300+ case 'string':
301+ return value;
302+ case 'object':
303+ if (Array.isArray(value)) {
304+ return value.map(stringifyArrayItem).join(' ');
305+ }
306+ if (value === null) {
307+ return '';
308+ }
309+ return value.toString();
310+ default:
311+ return JSON.stringify(value);
312+ }
313+ }
314+ exports.stringifyForShell = stringifyForShell;
315+
316+
269317/***/ }),
270318
271319/***/ 2013:
@@ -527,9 +575,19 @@ function run() {
527575 const output = core.getInput(common_1.inputs.OUTPUT, { required: true });
528576 console.log('patterns: ' + JSON.stringify(pathPatterns, undefined, 2));
529577 const changedFiles = yield (0, common_1.getChangedFiles)(token);
530- const filteredFiles = (0, common_1.filterPaths)(changedFiles, pathPatterns);
578+ const filteredFiles = pathPatterns.length > 0
579+ ? changedFiles.filter(({ path }) => (0, common_1.testPath)(path, pathPatterns))
580+ : changedFiles;
531581 (0, common_1.ensureDir)(output);
532- fs.writeFileSync(output, JSON.stringify(filteredFiles.map(filename => ({ filename })), undefined, 2));
582+ fs.writeFileSync(output, JSON.stringify(filteredFiles.map(({ path }) => ({ filename: path })), undefined, 2));
583+ (0, common_1.setOutputs)({
584+ json: JSON.stringify({
585+ files: filteredFiles,
586+ count: filteredFiles.length,
587+ }),
588+ files: filteredFiles.map(e => e.path),
589+ count: filteredFiles.length,
590+ });
533591 }
534592 catch (error) {
535593 if (error instanceof Error) {
0 commit comments