import * as fs from 'fs' ; import * as os from 'os' ; import * as path from 'path' ; import * as core from '@actions/core' ; import { v4 as uuidv4 } from 'uuid' ; export default class FileUtils { static readonly tempDirectory : string = process . env . RUNNER_TEMP || os . tmpdir ( ) ; static async createScriptFile ( inlineScript ) { const fileName = FileUtils . getFileName ( ) ; const filePath = path . join ( FileUtils . tempDirectory , fileName ) ; fs . writeFileSync ( filePath , inlineScript , 'utf-8' ) ; return filePath ; } private static getFileName ( ) { return `${ uuidv4 ( ) }.ps1` ; } static async deleteFile ( filePath ) { if ( fs . existsSync ( filePath ) ) { try { fs . unlinkSync ( filePath ) ; } catch ( err ) { core . warning ( err . toString ( ) ) ; } } } static pathExists ( path ) { return fs . existsSync ( path ) ; } }