1414 * limitations under the License.
1515 */
1616
17- import os from 'os' ;
18- import path from 'path' ;
1917import * as core from '@actions/core' ;
2018import * as semver from 'semver' ;
2119
@@ -25,6 +23,20 @@ export interface UndockOpts {
2523 binPath ?: string ;
2624}
2725
26+ export interface UndockRunOpts {
27+ source : string ;
28+ dist : string ;
29+ logLevel ?: string ;
30+ logCaller ?: boolean ;
31+ cacheDir ?: string ;
32+ platform ?: string ;
33+ all ?: boolean ;
34+ include ?: Array < string > ;
35+ insecure ?: boolean ;
36+ rmDist ?: boolean ;
37+ wrap ?: boolean ;
38+ }
39+
2840export class Undock {
2941 private readonly binPath : string ;
3042 private _version : string ;
@@ -36,8 +48,47 @@ export class Undock {
3648 this . _versionOnce = false ;
3749 }
3850
39- static get cacheDir ( ) : string {
40- return process . env . UNDOCK_CACHE_DIR || path . join ( os . homedir ( ) , '.local' , 'share' , 'undock' , 'cache' ) ;
51+ public async run ( opts : UndockRunOpts ) : Promise < void > {
52+ if ( ! opts . source ) {
53+ throw new Error ( 'source is required' ) ;
54+ }
55+ if ( ! opts . dist ) {
56+ throw new Error ( 'dist is required' ) ;
57+ }
58+ const args : Array < string > = [ ] ;
59+ if ( opts . logLevel ) {
60+ args . push ( `--log-level=${ opts . logLevel } ` ) ;
61+ }
62+ if ( opts . logCaller ) {
63+ args . push ( '--log-caller' ) ;
64+ }
65+ if ( opts . cacheDir ) {
66+ args . push ( `--cachedir=${ opts . cacheDir } ` ) ;
67+ }
68+ if ( opts . platform ) {
69+ args . push ( `--platform=${ opts . platform } ` ) ;
70+ }
71+ if ( opts . all ) {
72+ args . push ( '--all' ) ;
73+ }
74+ if ( opts . include ) {
75+ opts . include . forEach ( i => {
76+ args . push ( `--include=${ i } ` ) ;
77+ } ) ;
78+ }
79+ if ( opts . insecure ) {
80+ args . push ( '--insecure' ) ;
81+ }
82+ if ( opts . rmDist ) {
83+ args . push ( '--rm-dist' ) ;
84+ }
85+ if ( opts . wrap ) {
86+ args . push ( '--wrap' ) ;
87+ }
88+ args . push ( opts . source , opts . dist ) ;
89+ await Exec . exec ( this . binPath , args , {
90+ failOnStdErr : false
91+ } ) ;
4192 }
4293
4394 public async isAvailable ( ) : Promise < boolean > {
0 commit comments