file import { ipcRenderer , remote } from "electron" ; import { Action , ActionRequest , Target } from "./../../common/Objects/ActionRequest" ; const dialog = remote . dialog ; /**
 * The type of the callback that's called when the user is done
 * looking for a file (dialog box is closed)
 *
 * The first arg is the path to the file (maybe null)
 *
 * The second arg is the error message, if applicable (maybe null)
 */ type FileFoundCallback = ( filepath : string , errorMsg : string ) => void ; async param { FileFoundCallback } callback export async function lookForFile ( callback ) { const currentWindow = remote . getCurrentWindow ( ) ; dialog . showOpenDialog ( currentWindow , { title : "Select a .csv file" , filters : [ { name : "Comma-separated values" , extensions : [ "csv" ] , } , ] , properties : [ "openFile" ] , } ) . then ( ( result ) => { if ( result . canceled ) { callback ( null , "No file selected!" ) ; } else { const files = result . filePaths ; if ( files ) { if ( files . length > 1 ) { callback ( null , "Too many files selected!" ) ; } else if ( files . length === 1 ) { callback ( files [ 0 ] , "" ) ; } } else { callback ( null , "No file selected!" ) ; } } } ) ; } param { string } filepath param { string } subdir param { string } repoUrl param { string } branch param { string } commitMsg export function publish ( filepath , subdir , repoUrl , branch , commitMsg , forApache , checkUrl ) { ipcRenderer . send ( "request-action" , new ActionRequest ( Action . publish , filepath , subdir , repoUrl , branch , commitMsg , forApache ? Target . apache : Target . nginx ) ) ; } export function validate ( filepath , subdir , repoUrl , branch , commitMsg , forApache ) { ipcRenderer . send ( "request-action" , new ActionRequest ( Action . validate , filepath , subdir , repoUrl , branch , commitMsg , forApache ? Target . apache : Target . nginx ) ) ; }