Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Using platform-agnostic homedir() as output dir #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/FilesHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {setOutput as coreSetOutput, debug as coreDebug} from '@actions/core'
import {writeFileSync} from 'fs'
import {homedir} from 'os'
import {ChangedFiles} from 'typings/ChangedFiles'
import {GitHubFile} from 'typings/GitHubFile'
import {getErrorString} from './UtilsHelper'
Expand Down Expand Up @@ -89,16 +90,15 @@ export function writeFiles(format: string, key: string, files: string[]): void {
try {
const ext = getFormatExt(format)
const fileName = key === 'files' ? `${key}${ext}` : `files_${key}${ext}`
const filePath = `${homedir()}/${fileName}`
coreDebug(
`Writing output file ${
process.env.HOME
}/${fileName} with ${format} and files ${JSON.stringify(files, null, 2)}`
)
writeFileSync(
`${process.env.HOME}/${fileName}`,
formatChangedFiles(format, files),
'utf-8'
`Writing output file ${filePath} with ${format} and files ${JSON.stringify(
files,
null,
2
)}`
)
writeFileSync(filePath, formatChangedFiles(format, files), 'utf-8')
} catch (error) {
const eString = `There was an issue writing output files.`
throw new Error(
Expand Down