diff --git a/main.js b/main.js index f06f28e..2a2913a 100644 --- a/main.js +++ b/main.js @@ -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) { @@ -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);