diff --git a/build/index.js b/build/index.js index fca6d0a..5e20b3d 100644 --- a/build/index.js +++ b/build/index.js @@ -31,6 +31,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(2186)); +const fs = __importStar(__nccwpck_require__(7147)); const exec_1 = __nccwpck_require__(1514); const execute = async (command, options = {}) => { let stdOut = ""; @@ -66,10 +67,14 @@ const run = async () => { else { core.debug(`Files to format: ${files.join(', ')}`); for (const file of files) { - const { err, stdOut } = await execute(`rstfmt "${file}" > "${file}"`, { silent: false }); + const { err, stdOut } = await execute(`rstfmt "${file}"`, { silent: false }); if (err) { core.setFailed(stdOut); } + else { + // Write the formatted content back to the file. + fs.writeFileSync(file, stdOut); + } } } }); diff --git a/index.ts b/index.ts index 0f37a16..2b8fc8a 100644 --- a/index.ts +++ b/index.ts @@ -47,9 +47,12 @@ const run = async () => { } else { core.debug(`Files to format: ${files.join(', ')}`); for (const file of files) { - const { err, stdOut } = await execute(`rstfmt "${file}" > "${file}"`, { silent: false }); + const { err, stdOut } = await execute(`rstfmt "${file}"`, { silent: false }); if (err) { core.setFailed(stdOut); + } else { + // Write the formatted content back to the file. + fs.writeFileSync(file, stdOut); } } }