docker: install and download methods for macos and windows

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2023-02-27 09:10:57 +01:00
parent 964381b7e9
commit 4d66b2fa08
11 changed files with 469 additions and 3 deletions

View File

@@ -14,7 +14,9 @@
* limitations under the License.
*/
import fs from 'fs';
import * as core from '@actions/core';
import * as io from '@actions/io';
import {parse} from 'csv-parse/sync';
export interface InputListOpts {
@@ -71,4 +73,26 @@ export class Util {
}
return true;
}
public static async powershellCommand(script: string, params: Record<string, string>) {
const powershellPath: string = await io.which('powershell', true);
const escapedScript = script.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedParams: string[] = [];
for (const key in params) {
escapedParams.push(`-${key} '${params[key].replace(/'/g, "''").replace(/"|\n|\r/g, '')}'`);
}
return {
command: `"${powershellPath}"`,
args: ['-NoLogo', '-Sta', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-Command', `& '${escapedScript}' ${escapedParams.join(' ')}`]
};
}
public static isDirectory(p) {
try {
return fs.lstatSync(p).isDirectory();
} catch (_) {
// noop
}
return false;
}
}