Skip to content

Commit

Permalink
Add the ability to specify the working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Jan 26, 2024
1 parent 5916541 commit 22d7494
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { exec } = require('child_process');
const fs = require('fs');
const tagPrefix = `${process.env.INPUT_PREFIX || ''}*`;
const workingDirectory = process.env.INPUT_WORKINGDIRECTORY || null;

exec(`git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/${tagPrefix}"`, (err, tag, stderr) => {
exec(`git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/${tagPrefix}"`, {cwd: workingDirectory}, (err, tag, stderr) => {
tag = tag.trim();

if (err) {
Expand All @@ -19,7 +20,7 @@ exec(`git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)"
process.exit(0);
}

exec(`git log -1 --format=%at ${tag}`, (err, timestamp, stderr) => {
exec(`git log -1 --format=%at ${tag}`, {cwd: workingDirectory}, (err, timestamp, stderr) => {
if (err) {
console.log('\x1b[33m%s\x1b[0m', 'Could not find any timestamp because: ');
console.log('\x1b[31m%s\x1b[0m', stderr);
Expand Down

0 comments on commit 22d7494

Please sign in to comment.