New tool cache (#8)
* Consume new tool-cache * Fix tests * Fix workflow
This commit is contained in:
parent
594da1d3f0
commit
1acab72798
|
@ -7,8 +7,8 @@ import httpClient = require('typed-rest-client/HttpClient');
|
||||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||||
|
|
||||||
process.env['RUNNER_TOOLSDIRECTORY'] = toolDir;
|
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
||||||
process.env['RUNNER_TEMPDIRECTORY'] = tempDir;
|
process.env['RUNNER_TEMP'] = tempDir;
|
||||||
import * as installer from '../src/installer';
|
import * as installer from '../src/installer';
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# `@actions/core`
|
# `@actions/core`
|
||||||
|
|
||||||
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
See [src/core.ts](src/core.ts).
|
See [src/core.ts](src/core.ts).
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
interface CommandProperties {
|
interface CommandProperties {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
* Command Format:
|
* Command Format:
|
||||||
* ##[name key=value;key=value]message
|
* ##[name key=value;key=value]message
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* ##[warning]This is the user warning message
|
* ##[warning]This is the user warning message
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
||||||
*/
|
*/
|
||||||
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
||||||
export declare function issue(name: string, message: string): void;
|
export declare function issue(name: string, message: string): void;
|
||||||
export {};
|
export {};
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
* Command Format:
|
* Command Format:
|
||||||
* ##[name key=value;key=value]message
|
* ##[name key=value;key=value]message
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* ##[warning]This is the user warning message
|
* ##[warning]This is the user warning message
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
||||||
*/
|
*/
|
||||||
function issueCommand(command, properties, message) {
|
function issueCommand(command, properties, message) {
|
||||||
const cmd = new Command(command, properties, message);
|
const cmd = new Command(command, properties, message);
|
||||||
process.stdout.write(cmd.toString() + os.EOL);
|
process.stdout.write(cmd.toString() + os.EOL);
|
||||||
}
|
}
|
||||||
exports.issueCommand = issueCommand;
|
exports.issueCommand = issueCommand;
|
||||||
function issue(name, message) {
|
function issue(name, message) {
|
||||||
issueCommand(name, {}, message);
|
issueCommand(name, {}, message);
|
||||||
}
|
}
|
||||||
exports.issue = issue;
|
exports.issue = issue;
|
||||||
const CMD_PREFIX = '##[';
|
const CMD_PREFIX = '##[';
|
||||||
class Command {
|
class Command {
|
||||||
constructor(command, properties, message) {
|
constructor(command, properties, message) {
|
||||||
if (!command) {
|
if (!command) {
|
||||||
command = 'missing.command';
|
command = 'missing.command';
|
||||||
}
|
}
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
toString() {
|
toString() {
|
||||||
let cmdStr = CMD_PREFIX + this.command;
|
let cmdStr = CMD_PREFIX + this.command;
|
||||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
if (this.properties && Object.keys(this.properties).length > 0) {
|
||||||
cmdStr += ' ';
|
cmdStr += ' ';
|
||||||
for (const key in this.properties) {
|
for (const key in this.properties) {
|
||||||
if (this.properties.hasOwnProperty(key)) {
|
if (this.properties.hasOwnProperty(key)) {
|
||||||
const val = this.properties[key];
|
const val = this.properties[key];
|
||||||
if (val) {
|
if (val) {
|
||||||
// safely append the val - avoid blowing up when attempting to
|
// safely append the val - avoid blowing up when attempting to
|
||||||
// call .replace() if message is not a string for some reason
|
// call .replace() if message is not a string for some reason
|
||||||
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmdStr += ']';
|
cmdStr += ']';
|
||||||
// safely append the message - avoid blowing up when attempting to
|
// safely append the message - avoid blowing up when attempting to
|
||||||
// call .replace() if message is not a string for some reason
|
// call .replace() if message is not a string for some reason
|
||||||
const message = `${this.message || ''}`;
|
const message = `${this.message || ''}`;
|
||||||
cmdStr += escapeData(message);
|
cmdStr += escapeData(message);
|
||||||
return cmdStr;
|
return cmdStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function escapeData(s) {
|
function escapeData(s) {
|
||||||
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escape(s) {
|
function escape(s) {
|
||||||
return s
|
return s
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
.replace(/]/g, '%5D')
|
.replace(/]/g, '%5D')
|
||||||
.replace(/;/g, '%3B');
|
.replace(/;/g, '%3B');
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=command.js.map
|
//# sourceMappingURL=command.js.map
|
|
@ -1,57 +1,57 @@
|
||||||
/**
|
/**
|
||||||
* Interface for getInput options
|
* Interface for getInput options
|
||||||
*/
|
*/
|
||||||
export interface InputOptions {
|
export interface InputOptions {
|
||||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* sets env variable for this action and future actions in the job
|
* sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val the value of the variable
|
* @param val the value of the variable
|
||||||
*/
|
*/
|
||||||
export declare function exportVariable(name: string, val: string): void;
|
export declare function exportVariable(name: string, val: string): void;
|
||||||
/**
|
/**
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
* exports the variable and registers a secret which will get masked from logs
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val value of the secret
|
* @param val value of the secret
|
||||||
*/
|
*/
|
||||||
export declare function exportSecret(name: string, val: string): void;
|
export declare function exportSecret(name: string, val: string): void;
|
||||||
/**
|
/**
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
* Prepends inputPath to the PATH (for this action and future actions)
|
||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
export declare function addPath(inputPath: string): void;
|
export declare function addPath(inputPath: string): void;
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input. The value is also trimmed.
|
||||||
*
|
*
|
||||||
* @param name name of the input to get
|
* @param name name of the input to get
|
||||||
* @param options optional. See InputOptions.
|
* @param options optional. See InputOptions.
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export declare function getInput(name: string, options?: InputOptions): string;
|
export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
/**
|
/**
|
||||||
* Sets the action status to neutral
|
* Sets the action status to neutral
|
||||||
*/
|
*/
|
||||||
export declare function setNeutral(): void;
|
export declare function setNeutral(): void;
|
||||||
/**
|
/**
|
||||||
* Sets the action status to failed.
|
* Sets the action status to failed.
|
||||||
* When the action exits it will be with an exit code of 1
|
* When the action exits it will be with an exit code of 1
|
||||||
* @param message add error issue message
|
* @param message add error issue message
|
||||||
*/
|
*/
|
||||||
export declare function setFailed(message: string): void;
|
export declare function setFailed(message: string): void;
|
||||||
/**
|
/**
|
||||||
* Writes debug message to user log
|
* Writes debug message to user log
|
||||||
* @param message debug message
|
* @param message debug message
|
||||||
*/
|
*/
|
||||||
export declare function debug(message: string): void;
|
export declare function debug(message: string): void;
|
||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message
|
* @param message error issue message
|
||||||
*/
|
*/
|
||||||
export declare function error(message: string): void;
|
export declare function error(message: string): void;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds an warning issue
|
||||||
* @param message warning issue message
|
* @param message warning issue message
|
||||||
*/
|
*/
|
||||||
export declare function warning(message: string): void;
|
export declare function warning(message: string): void;
|
||||||
|
|
|
@ -1,100 +1,100 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const exit_1 = require("@actions/exit");
|
const exit_1 = require("@actions/exit");
|
||||||
const command_1 = require("./command");
|
const command_1 = require("./command");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Variables
|
// Variables
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* sets env variable for this action and future actions in the job
|
* sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val the value of the variable
|
* @param val the value of the variable
|
||||||
*/
|
*/
|
||||||
function exportVariable(name, val) {
|
function exportVariable(name, val) {
|
||||||
process.env[name] = val;
|
process.env[name] = val;
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
command_1.issueCommand('set-env', { name }, val);
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
* exports the variable and registers a secret which will get masked from logs
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val value of the secret
|
* @param val value of the secret
|
||||||
*/
|
*/
|
||||||
function exportSecret(name, val) {
|
function exportSecret(name, val) {
|
||||||
exportVariable(name, val);
|
exportVariable(name, val);
|
||||||
command_1.issueCommand('set-secret', {}, val);
|
command_1.issueCommand('set-secret', {}, val);
|
||||||
}
|
}
|
||||||
exports.exportSecret = exportSecret;
|
exports.exportSecret = exportSecret;
|
||||||
/**
|
/**
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
* Prepends inputPath to the PATH (for this action and future actions)
|
||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||||
}
|
}
|
||||||
exports.addPath = addPath;
|
exports.addPath = addPath;
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input. The value is also trimmed.
|
||||||
*
|
*
|
||||||
* @param name name of the input to get
|
* @param name name of the input to get
|
||||||
* @param options optional. See InputOptions.
|
* @param options optional. See InputOptions.
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
function getInput(name, options) {
|
function getInput(name, options) {
|
||||||
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
||||||
if (options && options.required && !val) {
|
if (options && options.required && !val) {
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
}
|
}
|
||||||
return val.trim();
|
return val.trim();
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Results
|
// Results
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Sets the action status to neutral
|
* Sets the action status to neutral
|
||||||
*/
|
*/
|
||||||
function setNeutral() {
|
function setNeutral() {
|
||||||
process.exitCode = exit_1.ExitCode.Neutral;
|
process.exitCode = exit_1.ExitCode.Neutral;
|
||||||
}
|
}
|
||||||
exports.setNeutral = setNeutral;
|
exports.setNeutral = setNeutral;
|
||||||
/**
|
/**
|
||||||
* Sets the action status to failed.
|
* Sets the action status to failed.
|
||||||
* When the action exits it will be with an exit code of 1
|
* When the action exits it will be with an exit code of 1
|
||||||
* @param message add error issue message
|
* @param message add error issue message
|
||||||
*/
|
*/
|
||||||
function setFailed(message) {
|
function setFailed(message) {
|
||||||
process.exitCode = exit_1.ExitCode.Failure;
|
process.exitCode = exit_1.ExitCode.Failure;
|
||||||
error(message);
|
error(message);
|
||||||
}
|
}
|
||||||
exports.setFailed = setFailed;
|
exports.setFailed = setFailed;
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Logging Commands
|
// Logging Commands
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Writes debug message to user log
|
* Writes debug message to user log
|
||||||
* @param message debug message
|
* @param message debug message
|
||||||
*/
|
*/
|
||||||
function debug(message) {
|
function debug(message) {
|
||||||
command_1.issueCommand('debug', {}, message);
|
command_1.issueCommand('debug', {}, message);
|
||||||
}
|
}
|
||||||
exports.debug = debug;
|
exports.debug = debug;
|
||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message
|
* @param message error issue message
|
||||||
*/
|
*/
|
||||||
function error(message) {
|
function error(message) {
|
||||||
command_1.issue('error', message);
|
command_1.issue('error', message);
|
||||||
}
|
}
|
||||||
exports.error = error;
|
exports.error = error;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds an warning issue
|
||||||
* @param message warning issue message
|
* @param message warning issue message
|
||||||
*/
|
*/
|
||||||
function warning(message) {
|
function warning(message) {
|
||||||
command_1.issue('warning', message);
|
command_1.issue('warning', message);
|
||||||
}
|
}
|
||||||
exports.warning = warning;
|
exports.warning = warning;
|
||||||
//# sourceMappingURL=core.js.map
|
//# sourceMappingURL=core.js.map
|
|
@ -1,7 +1,7 @@
|
||||||
# `@actions/exec`
|
# `@actions/exec`
|
||||||
|
|
||||||
> Functions necessary for running tools on the command line
|
> Functions necessary for running tools on the command line
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
See [src/exec.ts](src/exec.ts).
|
See [src/exec.ts](src/exec.ts).
|
|
@ -1,12 +1,12 @@
|
||||||
import * as im from './interfaces';
|
import * as im from './interfaces';
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
* Returns promise with return code
|
* Returns promise with return code
|
||||||
*
|
*
|
||||||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||||||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||||||
* @param options optional exec options. See ExecOptions
|
* @param options optional exec options. See ExecOptions
|
||||||
* @returns Promise<number> exit code
|
* @returns Promise<number> exit code
|
||||||
*/
|
*/
|
||||||
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;
|
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const tr = require("./toolrunner");
|
const tr = require("./toolrunner");
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
* Returns promise with return code
|
* Returns promise with return code
|
||||||
*
|
*
|
||||||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||||||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||||||
* @param options optional exec options. See ExecOptions
|
* @param options optional exec options. See ExecOptions
|
||||||
* @returns Promise<number> exit code
|
* @returns Promise<number> exit code
|
||||||
*/
|
*/
|
||||||
function exec(commandLine, args, options) {
|
function exec(commandLine, args, options) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const commandArgs = tr.argStringToArray(commandLine);
|
const commandArgs = tr.argStringToArray(commandLine);
|
||||||
if (commandArgs.length === 0) {
|
if (commandArgs.length === 0) {
|
||||||
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
||||||
}
|
}
|
||||||
// Path to tool to execute should be first arg
|
// Path to tool to execute should be first arg
|
||||||
const toolPath = commandArgs[0];
|
const toolPath = commandArgs[0];
|
||||||
args = commandArgs.slice(1).concat(args || []);
|
args = commandArgs.slice(1).concat(args || []);
|
||||||
const runner = new tr.ToolRunner(toolPath, args, options);
|
const runner = new tr.ToolRunner(toolPath, args, options);
|
||||||
return runner.exec();
|
return runner.exec();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.exec = exec;
|
exports.exec = exec;
|
||||||
//# sourceMappingURL=exec.js.map
|
//# sourceMappingURL=exec.js.map
|
|
@ -1,35 +1,35 @@
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import * as stream from 'stream';
|
import * as stream from 'stream';
|
||||||
/**
|
/**
|
||||||
* Interface for exec options
|
* Interface for exec options
|
||||||
*/
|
*/
|
||||||
export interface ExecOptions {
|
export interface ExecOptions {
|
||||||
/** optional working directory. defaults to current */
|
/** optional working directory. defaults to current */
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
/** optional envvar dictionary. defaults to current process's env */
|
/** optional envvar dictionary. defaults to current process's env */
|
||||||
env?: {
|
env?: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
/** optional. defaults to false */
|
/** optional. defaults to false */
|
||||||
silent?: boolean;
|
silent?: boolean;
|
||||||
/** optional out stream to use. Defaults to process.stdout */
|
/** optional out stream to use. Defaults to process.stdout */
|
||||||
outStream?: stream.Writable;
|
outStream?: stream.Writable;
|
||||||
/** optional err stream to use. Defaults to process.stderr */
|
/** optional err stream to use. Defaults to process.stderr */
|
||||||
errStream?: stream.Writable;
|
errStream?: stream.Writable;
|
||||||
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
|
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
|
||||||
windowsVerbatimArguments?: boolean;
|
windowsVerbatimArguments?: boolean;
|
||||||
/** optional. whether to fail if output to stderr. defaults to false */
|
/** optional. whether to fail if output to stderr. defaults to false */
|
||||||
failOnStdErr?: boolean;
|
failOnStdErr?: boolean;
|
||||||
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
|
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
|
||||||
ignoreReturnCode?: boolean;
|
ignoreReturnCode?: boolean;
|
||||||
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
|
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
|
||||||
delay?: number;
|
delay?: number;
|
||||||
/** optional. Listeners for output. Callback functions that will be called on these events */
|
/** optional. Listeners for output. Callback functions that will be called on these events */
|
||||||
listeners?: {
|
listeners?: {
|
||||||
stdout?: (data: Buffer) => void;
|
stdout?: (data: Buffer) => void;
|
||||||
stderr?: (data: Buffer) => void;
|
stderr?: (data: Buffer) => void;
|
||||||
stdline?: (data: string) => void;
|
stdline?: (data: string) => void;
|
||||||
errline?: (data: string) => void;
|
errline?: (data: string) => void;
|
||||||
debug?: (data: string) => void;
|
debug?: (data: string) => void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
//# sourceMappingURL=interfaces.js.map
|
//# sourceMappingURL=interfaces.js.map
|
|
@ -1,37 +1,37 @@
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import * as events from 'events';
|
import * as events from 'events';
|
||||||
import * as im from './interfaces';
|
import * as im from './interfaces';
|
||||||
export declare class ToolRunner extends events.EventEmitter {
|
export declare class ToolRunner extends events.EventEmitter {
|
||||||
constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
|
constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
|
||||||
private toolPath;
|
private toolPath;
|
||||||
private args;
|
private args;
|
||||||
private options;
|
private options;
|
||||||
private _debug;
|
private _debug;
|
||||||
private _getCommandString;
|
private _getCommandString;
|
||||||
private _processLineBuffer;
|
private _processLineBuffer;
|
||||||
private _getSpawnFileName;
|
private _getSpawnFileName;
|
||||||
private _getSpawnArgs;
|
private _getSpawnArgs;
|
||||||
private _endsWith;
|
private _endsWith;
|
||||||
private _isCmdFile;
|
private _isCmdFile;
|
||||||
private _windowsQuoteCmdArg;
|
private _windowsQuoteCmdArg;
|
||||||
private _uvQuoteCmdArg;
|
private _uvQuoteCmdArg;
|
||||||
private _cloneExecOptions;
|
private _cloneExecOptions;
|
||||||
private _getSpawnOptions;
|
private _getSpawnOptions;
|
||||||
/**
|
/**
|
||||||
* Exec a tool.
|
* Exec a tool.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
* Returns promise with return code
|
* Returns promise with return code
|
||||||
*
|
*
|
||||||
* @param tool path to tool to exec
|
* @param tool path to tool to exec
|
||||||
* @param options optional exec options. See ExecOptions
|
* @param options optional exec options. See ExecOptions
|
||||||
* @returns number
|
* @returns number
|
||||||
*/
|
*/
|
||||||
exec(): Promise<number>;
|
exec(): Promise<number>;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Convert an arg string to an array of args. Handles escaping
|
* Convert an arg string to an array of args. Handles escaping
|
||||||
*
|
*
|
||||||
* @param argString string of arguments
|
* @param argString string of arguments
|
||||||
* @returns string[] array of arguments
|
* @returns string[] array of arguments
|
||||||
*/
|
*/
|
||||||
export declare function argStringToArray(argString: string): string[];
|
export declare function argStringToArray(argString: string): string[];
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,49 +1,49 @@
|
||||||
# `@actions/io`
|
# `@actions/io`
|
||||||
|
|
||||||
> Core functions for cli filesystem scenarios
|
> Core functions for cli filesystem scenarios
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
/**
|
/**
|
||||||
* Copies a file or folder.
|
* Copies a file or folder.
|
||||||
*
|
*
|
||||||
* @param source source path
|
* @param source source path
|
||||||
* @param dest destination path
|
* @param dest destination path
|
||||||
* @param options optional. See CopyOptions.
|
* @param options optional. See CopyOptions.
|
||||||
*/
|
*/
|
||||||
export function cp(source: string, dest: string, options?: CopyOptions): Promise<void>
|
export function cp(source: string, dest: string, options?: CopyOptions): Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a path recursively with force
|
* Remove a path recursively with force
|
||||||
*
|
*
|
||||||
* @param path path to remove
|
* @param path path to remove
|
||||||
*/
|
*/
|
||||||
export function rmRF(path: string): Promise<void>
|
export function rmRF(path: string): Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a directory. Creates the full path with folders in between
|
* Make a directory. Creates the full path with folders in between
|
||||||
*
|
*
|
||||||
* @param p path to create
|
* @param p path to create
|
||||||
* @returns Promise<void>
|
* @returns Promise<void>
|
||||||
*/
|
*/
|
||||||
export function mkdirP(p: string): Promise<void>
|
export function mkdirP(p: string): Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves a path.
|
* Moves a path.
|
||||||
*
|
*
|
||||||
* @param source source path
|
* @param source source path
|
||||||
* @param dest destination path
|
* @param dest destination path
|
||||||
* @param options optional. See CopyOptions.
|
* @param options optional. See CopyOptions.
|
||||||
*/
|
*/
|
||||||
export function mv(source: string, dest: string, options?: CopyOptions): Promise<void>
|
export function mv(source: string, dest: string, options?: CopyOptions): Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
||||||
*
|
*
|
||||||
* @param tool name of the tool
|
* @param tool name of the tool
|
||||||
* @param options optional. See WhichOptions.
|
* @param options optional. See WhichOptions.
|
||||||
* @returns Promise<string> path to tool
|
* @returns Promise<string> path to tool
|
||||||
*/
|
*/
|
||||||
export function which(tool: string, options?: WhichOptions): Promise<string>
|
export function which(tool: string, options?: WhichOptions): Promise<string>
|
||||||
```
|
```
|
|
@ -1,29 +1,29 @@
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
export declare const copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, unlink: typeof fs.promises.unlink;
|
export declare const copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, unlink: typeof fs.promises.unlink;
|
||||||
export declare const IS_WINDOWS: boolean;
|
export declare const IS_WINDOWS: boolean;
|
||||||
export declare function exists(fsPath: string): Promise<boolean>;
|
export declare function exists(fsPath: string): Promise<boolean>;
|
||||||
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
|
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
|
||||||
/**
|
/**
|
||||||
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
||||||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
||||||
*/
|
*/
|
||||||
export declare function isRooted(p: string): boolean;
|
export declare function isRooted(p: string): boolean;
|
||||||
/**
|
/**
|
||||||
* Recursively create a directory at `fsPath`.
|
* Recursively create a directory at `fsPath`.
|
||||||
*
|
*
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
* This implementation is optimistic, meaning it attempts to create the full
|
||||||
* path first, and backs up the path stack from there.
|
* path first, and backs up the path stack from there.
|
||||||
*
|
*
|
||||||
* @param fsPath The path to create
|
* @param fsPath The path to create
|
||||||
* @param maxDepth The maximum recursion depth
|
* @param maxDepth The maximum recursion depth
|
||||||
* @param depth The current recursion depth
|
* @param depth The current recursion depth
|
||||||
*/
|
*/
|
||||||
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
|
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
* Best effort attempt to determine whether a file exists and is executable.
|
||||||
* @param filePath file path to check
|
* @param filePath file path to check
|
||||||
* @param extensions additional file extensions to try
|
* @param extensions additional file extensions to try
|
||||||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
||||||
*/
|
*/
|
||||||
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
||||||
|
|
|
@ -1,194 +1,194 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var _a;
|
var _a;
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const assert_1 = require("assert");
|
const assert_1 = require("assert");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
_a = fs.promises, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.unlink = _a.unlink;
|
_a = fs.promises, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.unlink = _a.unlink;
|
||||||
exports.IS_WINDOWS = process.platform === 'win32';
|
exports.IS_WINDOWS = process.platform === 'win32';
|
||||||
function exists(fsPath) {
|
function exists(fsPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
yield exports.stat(fsPath);
|
yield exports.stat(fsPath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err.code === 'ENOENT') {
|
if (err.code === 'ENOENT') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.exists = exists;
|
exports.exists = exists;
|
||||||
function isDirectory(fsPath, useStat = false) {
|
function isDirectory(fsPath, useStat = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
|
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
|
||||||
return stats.isDirectory();
|
return stats.isDirectory();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.isDirectory = isDirectory;
|
exports.isDirectory = isDirectory;
|
||||||
/**
|
/**
|
||||||
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
||||||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
||||||
*/
|
*/
|
||||||
function isRooted(p) {
|
function isRooted(p) {
|
||||||
p = normalizeSeparators(p);
|
p = normalizeSeparators(p);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
throw new Error('isRooted() parameter "p" cannot be empty');
|
throw new Error('isRooted() parameter "p" cannot be empty');
|
||||||
}
|
}
|
||||||
if (exports.IS_WINDOWS) {
|
if (exports.IS_WINDOWS) {
|
||||||
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
|
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
|
||||||
); // e.g. C: or C:\hello
|
); // e.g. C: or C:\hello
|
||||||
}
|
}
|
||||||
return p.startsWith('/');
|
return p.startsWith('/');
|
||||||
}
|
}
|
||||||
exports.isRooted = isRooted;
|
exports.isRooted = isRooted;
|
||||||
/**
|
/**
|
||||||
* Recursively create a directory at `fsPath`.
|
* Recursively create a directory at `fsPath`.
|
||||||
*
|
*
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
* This implementation is optimistic, meaning it attempts to create the full
|
||||||
* path first, and backs up the path stack from there.
|
* path first, and backs up the path stack from there.
|
||||||
*
|
*
|
||||||
* @param fsPath The path to create
|
* @param fsPath The path to create
|
||||||
* @param maxDepth The maximum recursion depth
|
* @param maxDepth The maximum recursion depth
|
||||||
* @param depth The current recursion depth
|
* @param depth The current recursion depth
|
||||||
*/
|
*/
|
||||||
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
|
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
assert_1.ok(fsPath, 'a path argument must be provided');
|
assert_1.ok(fsPath, 'a path argument must be provided');
|
||||||
fsPath = path.resolve(fsPath);
|
fsPath = path.resolve(fsPath);
|
||||||
if (depth >= maxDepth)
|
if (depth >= maxDepth)
|
||||||
return exports.mkdir(fsPath);
|
return exports.mkdir(fsPath);
|
||||||
try {
|
try {
|
||||||
yield exports.mkdir(fsPath);
|
yield exports.mkdir(fsPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
switch (err.code) {
|
switch (err.code) {
|
||||||
case 'ENOENT': {
|
case 'ENOENT': {
|
||||||
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
|
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
|
||||||
yield exports.mkdir(fsPath);
|
yield exports.mkdir(fsPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
let stats;
|
let stats;
|
||||||
try {
|
try {
|
||||||
stats = yield exports.stat(fsPath);
|
stats = yield exports.stat(fsPath);
|
||||||
}
|
}
|
||||||
catch (err2) {
|
catch (err2) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
if (!stats.isDirectory())
|
if (!stats.isDirectory())
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.mkdirP = mkdirP;
|
exports.mkdirP = mkdirP;
|
||||||
/**
|
/**
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
* Best effort attempt to determine whether a file exists and is executable.
|
||||||
* @param filePath file path to check
|
* @param filePath file path to check
|
||||||
* @param extensions additional file extensions to try
|
* @param extensions additional file extensions to try
|
||||||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
||||||
*/
|
*/
|
||||||
function tryGetExecutablePath(filePath, extensions) {
|
function tryGetExecutablePath(filePath, extensions) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let stats = undefined;
|
let stats = undefined;
|
||||||
try {
|
try {
|
||||||
// test file exists
|
// test file exists
|
||||||
stats = yield exports.stat(filePath);
|
stats = yield exports.stat(filePath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stats && stats.isFile()) {
|
if (stats && stats.isFile()) {
|
||||||
if (exports.IS_WINDOWS) {
|
if (exports.IS_WINDOWS) {
|
||||||
// on Windows, test for valid extension
|
// on Windows, test for valid extension
|
||||||
const upperExt = path.extname(filePath).toUpperCase();
|
const upperExt = path.extname(filePath).toUpperCase();
|
||||||
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
|
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isUnixExecutable(stats)) {
|
if (isUnixExecutable(stats)) {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// try each extension
|
// try each extension
|
||||||
const originalFilePath = filePath;
|
const originalFilePath = filePath;
|
||||||
for (const extension of extensions) {
|
for (const extension of extensions) {
|
||||||
filePath = originalFilePath + extension;
|
filePath = originalFilePath + extension;
|
||||||
stats = undefined;
|
stats = undefined;
|
||||||
try {
|
try {
|
||||||
stats = yield exports.stat(filePath);
|
stats = yield exports.stat(filePath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stats && stats.isFile()) {
|
if (stats && stats.isFile()) {
|
||||||
if (exports.IS_WINDOWS) {
|
if (exports.IS_WINDOWS) {
|
||||||
// preserve the case of the actual file (since an extension was appended)
|
// preserve the case of the actual file (since an extension was appended)
|
||||||
try {
|
try {
|
||||||
const directory = path.dirname(filePath);
|
const directory = path.dirname(filePath);
|
||||||
const upperName = path.basename(filePath).toUpperCase();
|
const upperName = path.basename(filePath).toUpperCase();
|
||||||
for (const actualName of yield exports.readdir(directory)) {
|
for (const actualName of yield exports.readdir(directory)) {
|
||||||
if (upperName === actualName.toUpperCase()) {
|
if (upperName === actualName.toUpperCase()) {
|
||||||
filePath = path.join(directory, actualName);
|
filePath = path.join(directory, actualName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
|
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
|
||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isUnixExecutable(stats)) {
|
if (isUnixExecutable(stats)) {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.tryGetExecutablePath = tryGetExecutablePath;
|
exports.tryGetExecutablePath = tryGetExecutablePath;
|
||||||
function normalizeSeparators(p) {
|
function normalizeSeparators(p) {
|
||||||
p = p || '';
|
p = p || '';
|
||||||
if (exports.IS_WINDOWS) {
|
if (exports.IS_WINDOWS) {
|
||||||
// convert slashes on Windows
|
// convert slashes on Windows
|
||||||
p = p.replace(/\//g, '\\');
|
p = p.replace(/\//g, '\\');
|
||||||
// remove redundant slashes
|
// remove redundant slashes
|
||||||
return p.replace(/\\\\+/g, '\\');
|
return p.replace(/\\\\+/g, '\\');
|
||||||
}
|
}
|
||||||
// remove redundant slashes
|
// remove redundant slashes
|
||||||
return p.replace(/\/\/+/g, '/');
|
return p.replace(/\/\/+/g, '/');
|
||||||
}
|
}
|
||||||
// on Mac/Linux, test the execute bit
|
// on Mac/Linux, test the execute bit
|
||||||
// R W X R W X R W X
|
// R W X R W X R W X
|
||||||
// 256 128 64 32 16 8 4 2 1
|
// 256 128 64 32 16 8 4 2 1
|
||||||
function isUnixExecutable(stats) {
|
function isUnixExecutable(stats) {
|
||||||
return ((stats.mode & 1) > 0 ||
|
return ((stats.mode & 1) > 0 ||
|
||||||
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
||||||
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=io-util.js.map
|
//# sourceMappingURL=io-util.js.map
|
|
@ -1,48 +1,48 @@
|
||||||
/**
|
/**
|
||||||
* Interface for cp/mv options
|
* Interface for cp/mv options
|
||||||
*/
|
*/
|
||||||
export interface CopyOptions {
|
export interface CopyOptions {
|
||||||
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */
|
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */
|
||||||
recursive?: boolean;
|
recursive?: boolean;
|
||||||
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Copies a file or folder.
|
* Copies a file or folder.
|
||||||
*
|
*
|
||||||
* @param source source path
|
* @param source source path
|
||||||
* @param dest destination path
|
* @param dest destination path
|
||||||
* @param options optional. See CopyOptions.
|
* @param options optional. See CopyOptions.
|
||||||
*/
|
*/
|
||||||
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Moves a path.
|
* Moves a path.
|
||||||
*
|
*
|
||||||
* @param source source path
|
* @param source source path
|
||||||
* @param dest destination path
|
* @param dest destination path
|
||||||
* @param options optional. See CopyOptions.
|
* @param options optional. See CopyOptions.
|
||||||
*/
|
*/
|
||||||
export declare function mv(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
export declare function mv(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Remove a path recursively with force
|
* Remove a path recursively with force
|
||||||
*
|
*
|
||||||
* @param inputPath path to remove
|
* @param inputPath path to remove
|
||||||
*/
|
*/
|
||||||
export declare function rmRF(inputPath: string): Promise<void>;
|
export declare function rmRF(inputPath: string): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Make a directory. Creates the full path with folders in between
|
* Make a directory. Creates the full path with folders in between
|
||||||
* Will throw if it fails
|
* Will throw if it fails
|
||||||
*
|
*
|
||||||
* @param fsPath path to create
|
* @param fsPath path to create
|
||||||
* @returns Promise<void>
|
* @returns Promise<void>
|
||||||
*/
|
*/
|
||||||
export declare function mkdirP(fsPath: string): Promise<void>;
|
export declare function mkdirP(fsPath: string): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
||||||
* If you check and the tool does not exist, it will throw.
|
* If you check and the tool does not exist, it will throw.
|
||||||
*
|
*
|
||||||
* @param tool name of the tool
|
* @param tool name of the tool
|
||||||
* @param check whether to check if tool exists
|
* @param check whether to check if tool exists
|
||||||
* @returns Promise<string> path to tool
|
* @returns Promise<string> path to tool
|
||||||
*/
|
*/
|
||||||
export declare function which(tool: string, check?: boolean): Promise<string>;
|
export declare function which(tool: string, check?: boolean): Promise<string>;
|
||||||
|
|
|
@ -1,262 +1,262 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const childProcess = require("child_process");
|
const childProcess = require("child_process");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const util_1 = require("util");
|
const util_1 = require("util");
|
||||||
const ioUtil = require("./io-util");
|
const ioUtil = require("./io-util");
|
||||||
const exec = util_1.promisify(childProcess.exec);
|
const exec = util_1.promisify(childProcess.exec);
|
||||||
/**
|
/**
|
||||||
* Copies a file or folder.
|
* Copies a file or folder.
|
||||||
*
|
*
|
||||||
* @param source source path
|
* @param source source path
|
||||||
* @param dest destination path
|
* @param dest destination path
|
||||||
* @param options optional. See CopyOptions.
|
* @param options optional. See CopyOptions.
|
||||||
*/
|
*/
|
||||||
function cp(source, dest, options = {}) {
|
function cp(source, dest, options = {}) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield move(source, dest, options, { deleteOriginal: false });
|
yield move(source, dest, options, { deleteOriginal: false });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.cp = cp;
|
exports.cp = cp;
|
||||||
/**
|
/**
|
||||||
* Moves a path.
|
* Moves a path.
|
||||||
*
|
*
|
||||||
* @param source source path
|
* @param source source path
|
||||||
* @param dest destination path
|
* @param dest destination path
|
||||||
* @param options optional. See CopyOptions.
|
* @param options optional. See CopyOptions.
|
||||||
*/
|
*/
|
||||||
function mv(source, dest, options = {}) {
|
function mv(source, dest, options = {}) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield move(source, dest, options, { deleteOriginal: true });
|
yield move(source, dest, options, { deleteOriginal: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.mv = mv;
|
exports.mv = mv;
|
||||||
/**
|
/**
|
||||||
* Remove a path recursively with force
|
* Remove a path recursively with force
|
||||||
*
|
*
|
||||||
* @param inputPath path to remove
|
* @param inputPath path to remove
|
||||||
*/
|
*/
|
||||||
function rmRF(inputPath) {
|
function rmRF(inputPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (ioUtil.IS_WINDOWS) {
|
if (ioUtil.IS_WINDOWS) {
|
||||||
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
||||||
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
||||||
try {
|
try {
|
||||||
if (yield ioUtil.isDirectory(inputPath, true)) {
|
if (yield ioUtil.isDirectory(inputPath, true)) {
|
||||||
yield exec(`rd /s /q "${inputPath}"`);
|
yield exec(`rd /s /q "${inputPath}"`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield exec(`del /f /a "${inputPath}"`);
|
yield exec(`del /f /a "${inputPath}"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
||||||
// other errors are valid
|
// other errors are valid
|
||||||
if (err.code !== 'ENOENT')
|
if (err.code !== 'ENOENT')
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
|
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
|
||||||
try {
|
try {
|
||||||
yield ioUtil.unlink(inputPath);
|
yield ioUtil.unlink(inputPath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
||||||
// other errors are valid
|
// other errors are valid
|
||||||
if (err.code !== 'ENOENT')
|
if (err.code !== 'ENOENT')
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let isDir = false;
|
let isDir = false;
|
||||||
try {
|
try {
|
||||||
isDir = yield ioUtil.isDirectory(inputPath);
|
isDir = yield ioUtil.isDirectory(inputPath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
||||||
// other errors are valid
|
// other errors are valid
|
||||||
if (err.code !== 'ENOENT')
|
if (err.code !== 'ENOENT')
|
||||||
throw err;
|
throw err;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
yield exec(`rm -rf "${inputPath}"`);
|
yield exec(`rm -rf "${inputPath}"`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield ioUtil.unlink(inputPath);
|
yield ioUtil.unlink(inputPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.rmRF = rmRF;
|
exports.rmRF = rmRF;
|
||||||
/**
|
/**
|
||||||
* Make a directory. Creates the full path with folders in between
|
* Make a directory. Creates the full path with folders in between
|
||||||
* Will throw if it fails
|
* Will throw if it fails
|
||||||
*
|
*
|
||||||
* @param fsPath path to create
|
* @param fsPath path to create
|
||||||
* @returns Promise<void>
|
* @returns Promise<void>
|
||||||
*/
|
*/
|
||||||
function mkdirP(fsPath) {
|
function mkdirP(fsPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield ioUtil.mkdirP(fsPath);
|
yield ioUtil.mkdirP(fsPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.mkdirP = mkdirP;
|
exports.mkdirP = mkdirP;
|
||||||
/**
|
/**
|
||||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
||||||
* If you check and the tool does not exist, it will throw.
|
* If you check and the tool does not exist, it will throw.
|
||||||
*
|
*
|
||||||
* @param tool name of the tool
|
* @param tool name of the tool
|
||||||
* @param check whether to check if tool exists
|
* @param check whether to check if tool exists
|
||||||
* @returns Promise<string> path to tool
|
* @returns Promise<string> path to tool
|
||||||
*/
|
*/
|
||||||
function which(tool, check) {
|
function which(tool, check) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!tool) {
|
if (!tool) {
|
||||||
throw new Error("parameter 'tool' is required");
|
throw new Error("parameter 'tool' is required");
|
||||||
}
|
}
|
||||||
// recursive when check=true
|
// recursive when check=true
|
||||||
if (check) {
|
if (check) {
|
||||||
const result = yield which(tool, false);
|
const result = yield which(tool, false);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if (ioUtil.IS_WINDOWS) {
|
if (ioUtil.IS_WINDOWS) {
|
||||||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
|
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// build the list of extensions to try
|
// build the list of extensions to try
|
||||||
const extensions = [];
|
const extensions = [];
|
||||||
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
|
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
|
||||||
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
|
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
|
||||||
if (extension) {
|
if (extension) {
|
||||||
extensions.push(extension);
|
extensions.push(extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if it's rooted, return it if exists. otherwise return empty.
|
// if it's rooted, return it if exists. otherwise return empty.
|
||||||
if (ioUtil.isRooted(tool)) {
|
if (ioUtil.isRooted(tool)) {
|
||||||
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
// if any path separators, return empty
|
// if any path separators, return empty
|
||||||
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
|
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
// build the list of directories
|
// build the list of directories
|
||||||
//
|
//
|
||||||
// Note, technically "where" checks the current directory on Windows. From a task lib perspective,
|
// Note, technically "where" checks the current directory on Windows. From a task lib perspective,
|
||||||
// it feels like we should not do this. Checking the current directory seems like more of a use
|
// it feels like we should not do this. Checking the current directory seems like more of a use
|
||||||
// case of a shell, and the which() function exposed by the task lib should strive for consistency
|
// case of a shell, and the which() function exposed by the task lib should strive for consistency
|
||||||
// across platforms.
|
// across platforms.
|
||||||
const directories = [];
|
const directories = [];
|
||||||
if (process.env.PATH) {
|
if (process.env.PATH) {
|
||||||
for (const p of process.env.PATH.split(path.delimiter)) {
|
for (const p of process.env.PATH.split(path.delimiter)) {
|
||||||
if (p) {
|
if (p) {
|
||||||
directories.push(p);
|
directories.push(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return the first match
|
// return the first match
|
||||||
for (const directory of directories) {
|
for (const directory of directories) {
|
||||||
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
|
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
throw new Error(`which failed with message ${err.message}`);
|
throw new Error(`which failed with message ${err.message}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.which = which;
|
exports.which = which;
|
||||||
// Copies contents of source into dest, making any necessary folders along the way.
|
// Copies contents of source into dest, making any necessary folders along the way.
|
||||||
// Deletes the original copy if deleteOriginal is true
|
// Deletes the original copy if deleteOriginal is true
|
||||||
function copyDirectoryContents(source, dest, force, deleteOriginal = false) {
|
function copyDirectoryContents(source, dest, force, deleteOriginal = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (yield ioUtil.isDirectory(source)) {
|
if (yield ioUtil.isDirectory(source)) {
|
||||||
if (yield ioUtil.exists(dest)) {
|
if (yield ioUtil.exists(dest)) {
|
||||||
if (!(yield ioUtil.isDirectory(dest))) {
|
if (!(yield ioUtil.isDirectory(dest))) {
|
||||||
throw new Error(`${dest} is not a directory`);
|
throw new Error(`${dest} is not a directory`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield mkdirP(dest);
|
yield mkdirP(dest);
|
||||||
}
|
}
|
||||||
// Copy all child files, and directories recursively
|
// Copy all child files, and directories recursively
|
||||||
const sourceChildren = yield ioUtil.readdir(source);
|
const sourceChildren = yield ioUtil.readdir(source);
|
||||||
for (const newSource of sourceChildren) {
|
for (const newSource of sourceChildren) {
|
||||||
const newDest = path.join(dest, path.basename(newSource));
|
const newDest = path.join(dest, path.basename(newSource));
|
||||||
yield copyDirectoryContents(path.resolve(source, newSource), newDest, force, deleteOriginal);
|
yield copyDirectoryContents(path.resolve(source, newSource), newDest, force, deleteOriginal);
|
||||||
}
|
}
|
||||||
if (deleteOriginal) {
|
if (deleteOriginal) {
|
||||||
yield ioUtil.rmdir(source);
|
yield ioUtil.rmdir(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (force) {
|
if (force) {
|
||||||
yield ioUtil.copyFile(source, dest);
|
yield ioUtil.copyFile(source, dest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
|
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
|
||||||
}
|
}
|
||||||
if (deleteOriginal) {
|
if (deleteOriginal) {
|
||||||
yield ioUtil.unlink(source);
|
yield ioUtil.unlink(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function move(source, dest, options = {}, moveOptions) {
|
function move(source, dest, options = {}, moveOptions) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { force, recursive } = readCopyOptions(options);
|
const { force, recursive } = readCopyOptions(options);
|
||||||
if (yield ioUtil.isDirectory(source)) {
|
if (yield ioUtil.isDirectory(source)) {
|
||||||
if (!recursive) {
|
if (!recursive) {
|
||||||
throw new Error(`non-recursive cp failed, ${source} is a directory`);
|
throw new Error(`non-recursive cp failed, ${source} is a directory`);
|
||||||
}
|
}
|
||||||
// If directory exists, move source inside it. Otherwise, create it and move contents of source inside.
|
// If directory exists, move source inside it. Otherwise, create it and move contents of source inside.
|
||||||
if (yield ioUtil.exists(dest)) {
|
if (yield ioUtil.exists(dest)) {
|
||||||
if (!(yield ioUtil.isDirectory(dest))) {
|
if (!(yield ioUtil.isDirectory(dest))) {
|
||||||
throw new Error(`${dest} is not a directory`);
|
throw new Error(`${dest} is not a directory`);
|
||||||
}
|
}
|
||||||
dest = path.join(dest, path.basename(source));
|
dest = path.join(dest, path.basename(source));
|
||||||
}
|
}
|
||||||
yield copyDirectoryContents(source, dest, force, moveOptions.deleteOriginal);
|
yield copyDirectoryContents(source, dest, force, moveOptions.deleteOriginal);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((yield ioUtil.exists(dest)) && (yield ioUtil.isDirectory(dest))) {
|
if ((yield ioUtil.exists(dest)) && (yield ioUtil.isDirectory(dest))) {
|
||||||
dest = path.join(dest, path.basename(source));
|
dest = path.join(dest, path.basename(source));
|
||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
yield ioUtil.copyFile(source, dest);
|
yield ioUtil.copyFile(source, dest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
|
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
|
||||||
}
|
}
|
||||||
if (moveOptions.deleteOriginal) {
|
if (moveOptions.deleteOriginal) {
|
||||||
yield ioUtil.unlink(source);
|
yield ioUtil.unlink(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function readCopyOptions(options) {
|
function readCopyOptions(options) {
|
||||||
const force = options.force == null ? true : options.force;
|
const force = options.force == null ? true : options.force;
|
||||||
const recursive = Boolean(options.recursive);
|
const recursive = Boolean(options.recursive);
|
||||||
return { force, recursive };
|
return { force, recursive };
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=io.js.map
|
//# sourceMappingURL=io.js.map
|
|
@ -1,7 +1,7 @@
|
||||||
# `@actions/tool-cache`
|
# `@actions/tool-cache`
|
||||||
|
|
||||||
> Functions necessary for downloading and caching tools.
|
> Functions necessary for downloading and caching tools.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
See [src/tool-cache.ts](src/tool-cache.ts).
|
See [src/tool-cache.ts](src/tool-cache.ts).
|
|
@ -1,78 +1,78 @@
|
||||||
export declare class HTTPError extends Error {
|
export declare class HTTPError extends Error {
|
||||||
readonly httpStatusCode: number | undefined;
|
readonly httpStatusCode: number | undefined;
|
||||||
constructor(httpStatusCode: number | undefined);
|
constructor(httpStatusCode: number | undefined);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Download a tool from an url and stream it into a file
|
* Download a tool from an url and stream it into a file
|
||||||
*
|
*
|
||||||
* @param url url of tool to download
|
* @param url url of tool to download
|
||||||
* @returns path to downloaded tool
|
* @returns path to downloaded tool
|
||||||
*/
|
*/
|
||||||
export declare function downloadTool(url: string): Promise<string>;
|
export declare function downloadTool(url: string): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Extract a .7z file
|
* Extract a .7z file
|
||||||
*
|
*
|
||||||
* @param file path to the .7z file
|
* @param file path to the .7z file
|
||||||
* @param dest destination directory. Optional.
|
* @param dest destination directory. Optional.
|
||||||
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
||||||
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
||||||
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
||||||
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
||||||
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
||||||
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
||||||
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
||||||
* to 7zr.exe can be pass to this function.
|
* to 7zr.exe can be pass to this function.
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>;
|
export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Extract a tar
|
* Extract a tar
|
||||||
*
|
*
|
||||||
* @param file path to the tar
|
* @param file path to the tar
|
||||||
* @param dest destination directory. Optional.
|
* @param dest destination directory. Optional.
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
export declare function extractTar(file: string, dest?: string): Promise<string>;
|
export declare function extractTar(file: string, dest?: string): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Extract a zip
|
* Extract a zip
|
||||||
*
|
*
|
||||||
* @param file path to the zip
|
* @param file path to the zip
|
||||||
* @param dest destination directory. Optional.
|
* @param dest destination directory. Optional.
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
export declare function extractZip(file: string, dest?: string): Promise<string>;
|
export declare function extractZip(file: string, dest?: string): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Caches a directory and installs it into the tool cacheDir
|
* Caches a directory and installs it into the tool cacheDir
|
||||||
*
|
*
|
||||||
* @param sourceDir the directory to cache into tools
|
* @param sourceDir the directory to cache into tools
|
||||||
* @param tool tool name
|
* @param tool tool name
|
||||||
* @param version version of the tool. semver format
|
* @param version version of the tool. semver format
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
||||||
*/
|
*/
|
||||||
export declare function cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>;
|
export declare function cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Caches a downloaded file (GUID) and installs it
|
* Caches a downloaded file (GUID) and installs it
|
||||||
* into the tool cache with a given targetName
|
* into the tool cache with a given targetName
|
||||||
*
|
*
|
||||||
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
||||||
* @param targetFile the name of the file name in the tools directory
|
* @param targetFile the name of the file name in the tools directory
|
||||||
* @param tool tool name
|
* @param tool tool name
|
||||||
* @param version version of the tool. semver format
|
* @param version version of the tool. semver format
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
||||||
*/
|
*/
|
||||||
export declare function cacheFile(sourceFile: string, targetFile: string, tool: string, version: string, arch?: string): Promise<string>;
|
export declare function cacheFile(sourceFile: string, targetFile: string, tool: string, version: string, arch?: string): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Finds the path to a tool version in the local installed tool cache
|
* Finds the path to a tool version in the local installed tool cache
|
||||||
*
|
*
|
||||||
* @param toolName name of the tool
|
* @param toolName name of the tool
|
||||||
* @param versionSpec version of the tool
|
* @param versionSpec version of the tool
|
||||||
* @param arch optional arch. defaults to arch of computer
|
* @param arch optional arch. defaults to arch of computer
|
||||||
*/
|
*/
|
||||||
export declare function find(toolName: string, versionSpec: string, arch?: string): string;
|
export declare function find(toolName: string, versionSpec: string, arch?: string): string;
|
||||||
/**
|
/**
|
||||||
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
||||||
*
|
*
|
||||||
* @param toolName name of the tool
|
* @param toolName name of the tool
|
||||||
* @param arch optional arch. defaults to arch of computer
|
* @param arch optional arch. defaults to arch of computer
|
||||||
*/
|
*/
|
||||||
export declare function findAllVersions(toolName: string, arch?: string): string[];
|
export declare function findAllVersions(toolName: string, arch?: string): string[];
|
||||||
|
|
|
@ -1,436 +1,436 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const io = require("@actions/io");
|
const io = require("@actions/io");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const httpm = require("typed-rest-client/HttpClient");
|
const httpm = require("typed-rest-client/HttpClient");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const uuidV4 = require("uuid/v4");
|
const uuidV4 = require("uuid/v4");
|
||||||
const exec_1 = require("@actions/exec/lib/exec");
|
const exec_1 = require("@actions/exec/lib/exec");
|
||||||
const assert_1 = require("assert");
|
const assert_1 = require("assert");
|
||||||
class HTTPError extends Error {
|
class HTTPError extends Error {
|
||||||
constructor(httpStatusCode) {
|
constructor(httpStatusCode) {
|
||||||
super(`Unexpected HTTP response: ${httpStatusCode}`);
|
super(`Unexpected HTTP response: ${httpStatusCode}`);
|
||||||
this.httpStatusCode = httpStatusCode;
|
this.httpStatusCode = httpStatusCode;
|
||||||
Object.setPrototypeOf(this, new.target.prototype);
|
Object.setPrototypeOf(this, new.target.prototype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HTTPError = HTTPError;
|
exports.HTTPError = HTTPError;
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const userAgent = 'actions/tool-cache';
|
const userAgent = 'actions/tool-cache';
|
||||||
// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this)
|
// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this)
|
||||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
let tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||||
let cacheRoot = process.env['RUNNER_TOOLSDIRECTORY'] || '';
|
let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || '';
|
||||||
// If directories not found, place them in common temp locations
|
// If directories not found, place them in common temp locations
|
||||||
if (!tempDirectory || !cacheRoot) {
|
if (!tempDirectory || !cacheRoot) {
|
||||||
let baseLocation;
|
let baseLocation;
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
// On windows use the USERPROFILE env variable
|
// On windows use the USERPROFILE env variable
|
||||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
baseLocation = '/Users';
|
baseLocation = '/Users';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
baseLocation = '/home';
|
baseLocation = '/home';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tempDirectory) {
|
if (!tempDirectory) {
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||||
}
|
}
|
||||||
if (!cacheRoot) {
|
if (!cacheRoot) {
|
||||||
cacheRoot = path.join(baseLocation, 'actions', 'cache');
|
cacheRoot = path.join(baseLocation, 'actions', 'cache');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Download a tool from an url and stream it into a file
|
* Download a tool from an url and stream it into a file
|
||||||
*
|
*
|
||||||
* @param url url of tool to download
|
* @param url url of tool to download
|
||||||
* @returns path to downloaded tool
|
* @returns path to downloaded tool
|
||||||
*/
|
*/
|
||||||
function downloadTool(url) {
|
function downloadTool(url) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// Wrap in a promise so that we can resolve from within stream callbacks
|
// Wrap in a promise so that we can resolve from within stream callbacks
|
||||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const http = new httpm.HttpClient(userAgent, [], {
|
const http = new httpm.HttpClient(userAgent, [], {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 3
|
maxRetries: 3
|
||||||
});
|
});
|
||||||
const destPath = path.join(tempDirectory, uuidV4());
|
const destPath = path.join(tempDirectory, uuidV4());
|
||||||
yield io.mkdirP(tempDirectory);
|
yield io.mkdirP(tempDirectory);
|
||||||
core.debug(`Downloading ${url}`);
|
core.debug(`Downloading ${url}`);
|
||||||
core.debug(`Downloading ${destPath}`);
|
core.debug(`Downloading ${destPath}`);
|
||||||
if (fs.existsSync(destPath)) {
|
if (fs.existsSync(destPath)) {
|
||||||
throw new Error(`Destination file path ${destPath} already exists`);
|
throw new Error(`Destination file path ${destPath} already exists`);
|
||||||
}
|
}
|
||||||
const response = yield http.get(url);
|
const response = yield http.get(url);
|
||||||
if (response.message.statusCode !== 200) {
|
if (response.message.statusCode !== 200) {
|
||||||
const err = new HTTPError(response.message.statusCode);
|
const err = new HTTPError(response.message.statusCode);
|
||||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
const file = fs.createWriteStream(destPath);
|
const file = fs.createWriteStream(destPath);
|
||||||
file.on('open', () => __awaiter(this, void 0, void 0, function* () {
|
file.on('open', () => __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const stream = response.message.pipe(file);
|
const stream = response.message.pipe(file);
|
||||||
stream.on('close', () => {
|
stream.on('close', () => {
|
||||||
core.debug('download complete');
|
core.debug('download complete');
|
||||||
resolve(destPath);
|
resolve(destPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
file.on('error', err => {
|
file.on('error', err => {
|
||||||
file.end();
|
file.end();
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.downloadTool = downloadTool;
|
exports.downloadTool = downloadTool;
|
||||||
/**
|
/**
|
||||||
* Extract a .7z file
|
* Extract a .7z file
|
||||||
*
|
*
|
||||||
* @param file path to the .7z file
|
* @param file path to the .7z file
|
||||||
* @param dest destination directory. Optional.
|
* @param dest destination directory. Optional.
|
||||||
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
||||||
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
||||||
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
||||||
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
||||||
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
||||||
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
||||||
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
||||||
* to 7zr.exe can be pass to this function.
|
* to 7zr.exe can be pass to this function.
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
function extract7z(file, dest, _7zPath) {
|
function extract7z(file, dest, _7zPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
|
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
|
||||||
assert_1.ok(file, 'parameter "file" is required');
|
assert_1.ok(file, 'parameter "file" is required');
|
||||||
dest = dest || (yield _createExtractFolder(dest));
|
dest = dest || (yield _createExtractFolder(dest));
|
||||||
const originalCwd = process.cwd();
|
const originalCwd = process.cwd();
|
||||||
process.chdir(dest);
|
process.chdir(dest);
|
||||||
if (_7zPath) {
|
if (_7zPath) {
|
||||||
try {
|
try {
|
||||||
const args = [
|
const args = [
|
||||||
'x',
|
'x',
|
||||||
'-bb1',
|
'-bb1',
|
||||||
'-bd',
|
'-bd',
|
||||||
'-sccUTF-8',
|
'-sccUTF-8',
|
||||||
file
|
file
|
||||||
];
|
];
|
||||||
const options = {
|
const options = {
|
||||||
silent: true
|
silent: true
|
||||||
};
|
};
|
||||||
yield exec_1.exec(`"${_7zPath}"`, args, options);
|
yield exec_1.exec(`"${_7zPath}"`, args, options);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
process.chdir(originalCwd);
|
process.chdir(originalCwd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const escapedScript = path
|
const escapedScript = path
|
||||||
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
|
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
|
||||||
.replace(/'/g, "''")
|
.replace(/'/g, "''")
|
||||||
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
||||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||||
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||||
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
|
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
|
||||||
const args = [
|
const args = [
|
||||||
'-NoLogo',
|
'-NoLogo',
|
||||||
'-Sta',
|
'-Sta',
|
||||||
'-NoProfile',
|
'-NoProfile',
|
||||||
'-NonInteractive',
|
'-NonInteractive',
|
||||||
'-ExecutionPolicy',
|
'-ExecutionPolicy',
|
||||||
'Unrestricted',
|
'Unrestricted',
|
||||||
'-Command',
|
'-Command',
|
||||||
command
|
command
|
||||||
];
|
];
|
||||||
const options = {
|
const options = {
|
||||||
silent: true
|
silent: true
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const powershellPath = yield io.which('powershell', true);
|
const powershellPath = yield io.which('powershell', true);
|
||||||
yield exec_1.exec(`"${powershellPath}"`, args, options);
|
yield exec_1.exec(`"${powershellPath}"`, args, options);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
process.chdir(originalCwd);
|
process.chdir(originalCwd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.extract7z = extract7z;
|
exports.extract7z = extract7z;
|
||||||
/**
|
/**
|
||||||
* Extract a tar
|
* Extract a tar
|
||||||
*
|
*
|
||||||
* @param file path to the tar
|
* @param file path to the tar
|
||||||
* @param dest destination directory. Optional.
|
* @param dest destination directory. Optional.
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
function extractTar(file, dest) {
|
function extractTar(file, dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw new Error("parameter 'file' is required");
|
throw new Error("parameter 'file' is required");
|
||||||
}
|
}
|
||||||
dest = dest || (yield _createExtractFolder(dest));
|
dest = dest || (yield _createExtractFolder(dest));
|
||||||
const tarPath = yield io.which('tar', true);
|
const tarPath = yield io.which('tar', true);
|
||||||
yield exec_1.exec(`"${tarPath}"`, ['xzC', dest, '-f', file]);
|
yield exec_1.exec(`"${tarPath}"`, ['xzC', dest, '-f', file]);
|
||||||
return dest;
|
return dest;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.extractTar = extractTar;
|
exports.extractTar = extractTar;
|
||||||
/**
|
/**
|
||||||
* Extract a zip
|
* Extract a zip
|
||||||
*
|
*
|
||||||
* @param file path to the zip
|
* @param file path to the zip
|
||||||
* @param dest destination directory. Optional.
|
* @param dest destination directory. Optional.
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
function extractZip(file, dest) {
|
function extractZip(file, dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw new Error("parameter 'file' is required");
|
throw new Error("parameter 'file' is required");
|
||||||
}
|
}
|
||||||
dest = dest || (yield _createExtractFolder(dest));
|
dest = dest || (yield _createExtractFolder(dest));
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
yield extractZipWin(file, dest);
|
yield extractZipWin(file, dest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield extractZipNix(file, dest);
|
yield extractZipNix(file, dest);
|
||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.extractZip = extractZip;
|
exports.extractZip = extractZip;
|
||||||
function extractZipWin(file, dest) {
|
function extractZipWin(file, dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// build the powershell command
|
// build the powershell command
|
||||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
||||||
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||||
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
|
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
|
||||||
// run powershell
|
// run powershell
|
||||||
const powershellPath = yield io.which('powershell');
|
const powershellPath = yield io.which('powershell');
|
||||||
const args = [
|
const args = [
|
||||||
'-NoLogo',
|
'-NoLogo',
|
||||||
'-Sta',
|
'-Sta',
|
||||||
'-NoProfile',
|
'-NoProfile',
|
||||||
'-NonInteractive',
|
'-NonInteractive',
|
||||||
'-ExecutionPolicy',
|
'-ExecutionPolicy',
|
||||||
'Unrestricted',
|
'Unrestricted',
|
||||||
'-Command',
|
'-Command',
|
||||||
command
|
command
|
||||||
];
|
];
|
||||||
yield exec_1.exec(`"${powershellPath}"`, args);
|
yield exec_1.exec(`"${powershellPath}"`, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function extractZipNix(file, dest) {
|
function extractZipNix(file, dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
|
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
|
||||||
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Caches a directory and installs it into the tool cacheDir
|
* Caches a directory and installs it into the tool cacheDir
|
||||||
*
|
*
|
||||||
* @param sourceDir the directory to cache into tools
|
* @param sourceDir the directory to cache into tools
|
||||||
* @param tool tool name
|
* @param tool tool name
|
||||||
* @param version version of the tool. semver format
|
* @param version version of the tool. semver format
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
||||||
*/
|
*/
|
||||||
function cacheDir(sourceDir, tool, version, arch) {
|
function cacheDir(sourceDir, tool, version, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
version = semver.clean(version) || version;
|
version = semver.clean(version) || version;
|
||||||
arch = arch || os.arch();
|
arch = arch || os.arch();
|
||||||
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
||||||
core.debug(`source dir: ${sourceDir}`);
|
core.debug(`source dir: ${sourceDir}`);
|
||||||
if (!fs.statSync(sourceDir).isDirectory()) {
|
if (!fs.statSync(sourceDir).isDirectory()) {
|
||||||
throw new Error('sourceDir is not a directory');
|
throw new Error('sourceDir is not a directory');
|
||||||
}
|
}
|
||||||
// Create the tool dir
|
// Create the tool dir
|
||||||
const destPath = yield _createToolPath(tool, version, arch);
|
const destPath = yield _createToolPath(tool, version, arch);
|
||||||
// copy each child item. do not move. move can fail on Windows
|
// copy each child item. do not move. move can fail on Windows
|
||||||
// due to anti-virus software having an open handle on a file.
|
// due to anti-virus software having an open handle on a file.
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
for (const itemName of fs.readdirSync(sourceDir)) {
|
||||||
const s = path.join(sourceDir, itemName);
|
const s = path.join(sourceDir, itemName);
|
||||||
yield io.cp(s, destPath, { recursive: true });
|
yield io.cp(s, destPath, { recursive: true });
|
||||||
}
|
}
|
||||||
// write .complete
|
// write .complete
|
||||||
_completeToolPath(tool, version, arch);
|
_completeToolPath(tool, version, arch);
|
||||||
return destPath;
|
return destPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.cacheDir = cacheDir;
|
exports.cacheDir = cacheDir;
|
||||||
/**
|
/**
|
||||||
* Caches a downloaded file (GUID) and installs it
|
* Caches a downloaded file (GUID) and installs it
|
||||||
* into the tool cache with a given targetName
|
* into the tool cache with a given targetName
|
||||||
*
|
*
|
||||||
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
||||||
* @param targetFile the name of the file name in the tools directory
|
* @param targetFile the name of the file name in the tools directory
|
||||||
* @param tool tool name
|
* @param tool tool name
|
||||||
* @param version version of the tool. semver format
|
* @param version version of the tool. semver format
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
||||||
*/
|
*/
|
||||||
function cacheFile(sourceFile, targetFile, tool, version, arch) {
|
function cacheFile(sourceFile, targetFile, tool, version, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
version = semver.clean(version) || version;
|
version = semver.clean(version) || version;
|
||||||
arch = arch || os.arch();
|
arch = arch || os.arch();
|
||||||
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
||||||
core.debug(`source file: ${sourceFile}`);
|
core.debug(`source file: ${sourceFile}`);
|
||||||
if (!fs.statSync(sourceFile).isFile()) {
|
if (!fs.statSync(sourceFile).isFile()) {
|
||||||
throw new Error('sourceFile is not a file');
|
throw new Error('sourceFile is not a file');
|
||||||
}
|
}
|
||||||
// create the tool dir
|
// create the tool dir
|
||||||
const destFolder = yield _createToolPath(tool, version, arch);
|
const destFolder = yield _createToolPath(tool, version, arch);
|
||||||
// copy instead of move. move can fail on Windows due to
|
// copy instead of move. move can fail on Windows due to
|
||||||
// anti-virus software having an open handle on a file.
|
// anti-virus software having an open handle on a file.
|
||||||
const destPath = path.join(destFolder, targetFile);
|
const destPath = path.join(destFolder, targetFile);
|
||||||
core.debug(`destination file ${destPath}`);
|
core.debug(`destination file ${destPath}`);
|
||||||
yield io.cp(sourceFile, destPath);
|
yield io.cp(sourceFile, destPath);
|
||||||
// write .complete
|
// write .complete
|
||||||
_completeToolPath(tool, version, arch);
|
_completeToolPath(tool, version, arch);
|
||||||
return destFolder;
|
return destFolder;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.cacheFile = cacheFile;
|
exports.cacheFile = cacheFile;
|
||||||
/**
|
/**
|
||||||
* Finds the path to a tool version in the local installed tool cache
|
* Finds the path to a tool version in the local installed tool cache
|
||||||
*
|
*
|
||||||
* @param toolName name of the tool
|
* @param toolName name of the tool
|
||||||
* @param versionSpec version of the tool
|
* @param versionSpec version of the tool
|
||||||
* @param arch optional arch. defaults to arch of computer
|
* @param arch optional arch. defaults to arch of computer
|
||||||
*/
|
*/
|
||||||
function find(toolName, versionSpec, arch) {
|
function find(toolName, versionSpec, arch) {
|
||||||
if (!toolName) {
|
if (!toolName) {
|
||||||
throw new Error('toolName parameter is required');
|
throw new Error('toolName parameter is required');
|
||||||
}
|
}
|
||||||
if (!versionSpec) {
|
if (!versionSpec) {
|
||||||
throw new Error('versionSpec parameter is required');
|
throw new Error('versionSpec parameter is required');
|
||||||
}
|
}
|
||||||
arch = arch || os.arch();
|
arch = arch || os.arch();
|
||||||
// attempt to resolve an explicit version
|
// attempt to resolve an explicit version
|
||||||
if (!_isExplicitVersion(versionSpec)) {
|
if (!_isExplicitVersion(versionSpec)) {
|
||||||
const localVersions = findAllVersions(toolName, arch);
|
const localVersions = findAllVersions(toolName, arch);
|
||||||
const match = _evaluateVersions(localVersions, versionSpec);
|
const match = _evaluateVersions(localVersions, versionSpec);
|
||||||
versionSpec = match;
|
versionSpec = match;
|
||||||
}
|
}
|
||||||
// check for the explicit version in the cache
|
// check for the explicit version in the cache
|
||||||
let toolPath = '';
|
let toolPath = '';
|
||||||
if (versionSpec) {
|
if (versionSpec) {
|
||||||
versionSpec = semver.clean(versionSpec) || '';
|
versionSpec = semver.clean(versionSpec) || '';
|
||||||
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch);
|
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch);
|
||||||
core.debug(`checking cache: ${cachePath}`);
|
core.debug(`checking cache: ${cachePath}`);
|
||||||
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
|
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
|
||||||
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
|
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
|
||||||
toolPath = cachePath;
|
toolPath = cachePath;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.debug('not found');
|
core.debug('not found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toolPath;
|
return toolPath;
|
||||||
}
|
}
|
||||||
exports.find = find;
|
exports.find = find;
|
||||||
/**
|
/**
|
||||||
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
||||||
*
|
*
|
||||||
* @param toolName name of the tool
|
* @param toolName name of the tool
|
||||||
* @param arch optional arch. defaults to arch of computer
|
* @param arch optional arch. defaults to arch of computer
|
||||||
*/
|
*/
|
||||||
function findAllVersions(toolName, arch) {
|
function findAllVersions(toolName, arch) {
|
||||||
const versions = [];
|
const versions = [];
|
||||||
arch = arch || os.arch();
|
arch = arch || os.arch();
|
||||||
const toolPath = path.join(cacheRoot, toolName);
|
const toolPath = path.join(cacheRoot, toolName);
|
||||||
if (fs.existsSync(toolPath)) {
|
if (fs.existsSync(toolPath)) {
|
||||||
const children = fs.readdirSync(toolPath);
|
const children = fs.readdirSync(toolPath);
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (_isExplicitVersion(child)) {
|
if (_isExplicitVersion(child)) {
|
||||||
const fullPath = path.join(toolPath, child, arch || '');
|
const fullPath = path.join(toolPath, child, arch || '');
|
||||||
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
||||||
versions.push(child);
|
versions.push(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
exports.findAllVersions = findAllVersions;
|
exports.findAllVersions = findAllVersions;
|
||||||
function _createExtractFolder(dest) {
|
function _createExtractFolder(dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
// create a temp dir
|
// create a temp dir
|
||||||
dest = path.join(tempDirectory, uuidV4());
|
dest = path.join(tempDirectory, uuidV4());
|
||||||
}
|
}
|
||||||
yield io.mkdirP(dest);
|
yield io.mkdirP(dest);
|
||||||
return dest;
|
return dest;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function _createToolPath(tool, version, arch) {
|
function _createToolPath(tool, version, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
|
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
|
||||||
core.debug(`destination ${folderPath}`);
|
core.debug(`destination ${folderPath}`);
|
||||||
const markerPath = `${folderPath}.complete`;
|
const markerPath = `${folderPath}.complete`;
|
||||||
yield io.rmRF(folderPath);
|
yield io.rmRF(folderPath);
|
||||||
yield io.rmRF(markerPath);
|
yield io.rmRF(markerPath);
|
||||||
yield io.mkdirP(folderPath);
|
yield io.mkdirP(folderPath);
|
||||||
return folderPath;
|
return folderPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function _completeToolPath(tool, version, arch) {
|
function _completeToolPath(tool, version, arch) {
|
||||||
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
|
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
|
||||||
const markerPath = `${folderPath}.complete`;
|
const markerPath = `${folderPath}.complete`;
|
||||||
fs.writeFileSync(markerPath, '');
|
fs.writeFileSync(markerPath, '');
|
||||||
core.debug('finished caching tool');
|
core.debug('finished caching tool');
|
||||||
}
|
}
|
||||||
function _isExplicitVersion(versionSpec) {
|
function _isExplicitVersion(versionSpec) {
|
||||||
const c = semver.clean(versionSpec) || '';
|
const c = semver.clean(versionSpec) || '';
|
||||||
core.debug(`isExplicit: ${c}`);
|
core.debug(`isExplicit: ${c}`);
|
||||||
const valid = semver.valid(c) != null;
|
const valid = semver.valid(c) != null;
|
||||||
core.debug(`explicit? ${valid}`);
|
core.debug(`explicit? ${valid}`);
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
function _evaluateVersions(versions, versionSpec) {
|
function _evaluateVersions(versions, versionSpec) {
|
||||||
let version = '';
|
let version = '';
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
core.debug(`evaluating ${versions.length} versions`);
|
||||||
versions = versions.sort((a, b) => {
|
versions = versions.sort((a, b) => {
|
||||||
if (semver.gt(a, b)) {
|
if (semver.gt(a, b)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
});
|
});
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
for (let i = versions.length - 1; i >= 0; i--) {
|
||||||
const potential = versions[i];
|
const potential = versions[i];
|
||||||
const satisfied = semver.satisfies(potential, versionSpec);
|
const satisfied = semver.satisfies(potential, versionSpec);
|
||||||
if (satisfied) {
|
if (satisfied) {
|
||||||
version = potential;
|
version = potential;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version) {
|
if (version) {
|
||||||
core.debug(`matched: ${version}`);
|
core.debug(`matched: ${version}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.debug('match not found');
|
core.debug('match not found');
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=tool-cache.js.map
|
//# sourceMappingURL=tool-cache.js.map
|
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@
|
||||||
"_from": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
|
"_from": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
|
||||||
"_id": "@actions/tool-cache@0.0.0",
|
"_id": "@actions/tool-cache@0.0.0",
|
||||||
"_inBundle": false,
|
"_inBundle": false,
|
||||||
"_integrity": "sha512-NavDg5VFXDfbe9TpFuj+uOHacjg1bT3Wmo3DQuul3gsGRBEXyzhh2MWKnBZs/Zh7FE3prLmIqpbtymafNBFkIA==",
|
"_integrity": "sha512-CCJjXKGfqR34oo1mgKpUk63g3fcoIq+aNJBZ7b73aWGot0ddju2cefJrKjhEun4FI7gYsLYg+ayAUnbFwkGd4Q==",
|
||||||
"_location": "/@actions/tool-cache",
|
"_location": "/@actions/tool-cache",
|
||||||
"_phantomChildren": {},
|
"_phantomChildren": {},
|
||||||
"_requested": {
|
"_requested": {
|
||||||
|
@ -17,10 +17,11 @@
|
||||||
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-dotnet\\toolkit\\actions-tool-cache-0.0.0.tgz"
|
"fetchSpec": "C:\\Users\\damccorm\\Documents\\setup-dotnet\\toolkit\\actions-tool-cache-0.0.0.tgz"
|
||||||
},
|
},
|
||||||
"_requiredBy": [
|
"_requiredBy": [
|
||||||
|
"#USER",
|
||||||
"/"
|
"/"
|
||||||
],
|
],
|
||||||
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-dotnet\\toolkit\\actions-tool-cache-0.0.0.tgz",
|
"_resolved": "C:\\Users\\damccorm\\Documents\\setup-dotnet\\toolkit\\actions-tool-cache-0.0.0.tgz",
|
||||||
"_shasum": "fa216c10f724010a74602fd14881f25f5b008070",
|
"_shasum": "223a115ab2782ba0a7ad4a0a829030b9cb84eade",
|
||||||
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
|
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||||
"_where": "C:\\Users\\damccorm\\Documents\\setup-dotnet",
|
"_where": "C:\\Users\\damccorm\\Documents\\setup-dotnet",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Source,
|
[string]$Source,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$Target)
|
[string]$Target)
|
||||||
|
|
||||||
# This script translates the output from 7zdec into UTF8. Node has limited
|
# This script translates the output from 7zdec into UTF8. Node has limited
|
||||||
# built-in support for encodings.
|
# built-in support for encodings.
|
||||||
#
|
#
|
||||||
# 7zdec uses the system default code page. The system default code page varies
|
# 7zdec uses the system default code page. The system default code page varies
|
||||||
# depending on the locale configuration. On an en-US box, the system default code
|
# depending on the locale configuration. On an en-US box, the system default code
|
||||||
# page is Windows-1252.
|
# page is Windows-1252.
|
||||||
#
|
#
|
||||||
# Note, on a typical en-US box, testing with the 'ç' character is a good way to
|
# Note, on a typical en-US box, testing with the 'ç' character is a good way to
|
||||||
# determine whether data is passed correctly between processes. This is because
|
# determine whether data is passed correctly between processes. This is because
|
||||||
# the 'ç' character has a different code point across each of the common encodings
|
# the 'ç' character has a different code point across each of the common encodings
|
||||||
# on a typical en-US box, i.e.
|
# on a typical en-US box, i.e.
|
||||||
# 1) the default console-output code page (IBM437)
|
# 1) the default console-output code page (IBM437)
|
||||||
# 2) the system default code page (i.e. CP_ACP) (Windows-1252)
|
# 2) the system default code page (i.e. CP_ACP) (Windows-1252)
|
||||||
# 3) UTF8
|
# 3) UTF8
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default.
|
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default.
|
||||||
$stdout = [System.Console]::OpenStandardOutput()
|
$stdout = [System.Console]::OpenStandardOutput()
|
||||||
$utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM
|
$utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM
|
||||||
$writer = New-Object System.IO.StreamWriter($stdout, $utf8)
|
$writer = New-Object System.IO.StreamWriter($stdout, $utf8)
|
||||||
[System.Console]::SetOut($writer)
|
[System.Console]::SetOut($writer)
|
||||||
|
|
||||||
# All subsequent output must be written using [System.Console]::WriteLine(). In
|
# All subsequent output must be written using [System.Console]::WriteLine(). In
|
||||||
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer.
|
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer.
|
||||||
|
|
||||||
Set-Location -LiteralPath $Target
|
Set-Location -LiteralPath $Target
|
||||||
|
|
||||||
# Print the ##command.
|
# Print the ##command.
|
||||||
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe"
|
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe"
|
||||||
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"")
|
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"")
|
||||||
|
|
||||||
# The $OutputEncoding variable instructs PowerShell how to interpret the output
|
# The $OutputEncoding variable instructs PowerShell how to interpret the output
|
||||||
# from the external command.
|
# from the external command.
|
||||||
$OutputEncoding = [System.Text.Encoding]::Default
|
$OutputEncoding = [System.Text.Encoding]::Default
|
||||||
|
|
||||||
# Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe
|
# Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe
|
||||||
# will launch the external command in such a way that it inherits the streams.
|
# will launch the external command in such a way that it inherits the streams.
|
||||||
& $_7zdec x $Source 2>&1 |
|
& $_7zdec x $Source 2>&1 |
|
||||||
ForEach-Object {
|
ForEach-Object {
|
||||||
if ($_ -is [System.Management.Automation.ErrorRecord]) {
|
if ($_ -is [System.Management.Automation.ErrorRecord]) {
|
||||||
[System.Console]::WriteLine($_.Exception.Message)
|
[System.Console]::WriteLine($_.Exception.Message)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[System.Console]::WriteLine($_)
|
[System.Console]::WriteLine($_)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'")
|
[System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'")
|
||||||
[System.Console]::Out.Flush()
|
[System.Console]::Out.Flush()
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
102
package.json
102
package.json
|
@ -1,51 +1,51 @@
|
||||||
{
|
{
|
||||||
"name": "setup-dotnet",
|
"name": "setup-dotnet",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "setup dotnet action",
|
"description": "setup dotnet action",
|
||||||
"main": "lib/setup-dotnet.js",
|
"main": "lib/setup-dotnet.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/actions/setup-dotnet.git"
|
"url": "git+https://github.com/actions/setup-dotnet.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"actions",
|
"actions",
|
||||||
"dotnet",
|
"dotnet",
|
||||||
"setup"
|
"setup"
|
||||||
],
|
],
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "file:toolkit/actions-core-0.0.0.tgz",
|
"@actions/core": "file:toolkit/actions-core-0.0.0.tgz",
|
||||||
"@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz",
|
"@actions/exec": "file:toolkit/actions-exec-0.0.0.tgz",
|
||||||
"@actions/exit": "file:toolkit/actions-exit-0.0.0.tgz",
|
"@actions/exit": "file:toolkit/actions-exit-0.0.0.tgz",
|
||||||
"@actions/io": "file:toolkit/actions-io-0.0.0.tgz",
|
"@actions/io": "file:toolkit/actions-io-0.0.0.tgz",
|
||||||
"@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
"@actions/tool-cache": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
||||||
"semver": "^6.1.1",
|
"semver": "^6.1.1",
|
||||||
"typed-rest-client": "1.5.0"
|
"typed-rest-client": "1.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^24.0.13",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^12.0.4",
|
||||||
"@types/semver": "^6.0.0",
|
"@types/semver": "^6.0.0",
|
||||||
"husky": "^2.3.0",
|
"husky": "^2.3.0",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"jest-circus": "^24.7.1",
|
"jest-circus": "^24.7.1",
|
||||||
"prettier": "^1.17.1",
|
"prettier": "^1.17.1",
|
||||||
"ts-jest": "^24.0.2",
|
"ts-jest": "^24.0.2",
|
||||||
"typescript": "^3.5.1"
|
"typescript": "^3.5.1"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"skipCI": true,
|
"skipCI": true,
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "npm run build && npm run format",
|
"pre-commit": "npm run build && npm run format",
|
||||||
"post-commit": "npm prune --production && git add node_modules/* && git commit -m \"Husky commit correct node modules\""
|
"post-commit": "npm prune --production && git add node_modules/* && git commit -m \"Husky commit correct node modules\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue