mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-16 08:32:34 +00:00
Initial commit
This commit is contained in:
commit
cd5e05ffbf
23 changed files with 26743 additions and 0 deletions
36
wrapper/lib/output-listener.js
Normal file
36
wrapper/lib/output-listener.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Acts as a listener for @actions/exec, by capturing STDOUT and STDERR
|
||||
* streams, and exposing them via a contents attribute.
|
||||
*
|
||||
* @example
|
||||
* // Instantiate a new listener
|
||||
* const listener = new OutputListener();
|
||||
* // Register listener against STDOUT stream
|
||||
* await exec.exec('ls', ['-ltr'], {
|
||||
* listeners: {
|
||||
* stdout: listener.listener
|
||||
* }
|
||||
* });
|
||||
* // Log out STDOUT contents
|
||||
* console.log(listener.contents);
|
||||
*/
|
||||
class OutputListener {
|
||||
constructor () {
|
||||
this._buff = [];
|
||||
}
|
||||
|
||||
get listener () {
|
||||
const listen = function listen (data) {
|
||||
this._buff.push(data);
|
||||
};
|
||||
return listen.bind(this);
|
||||
}
|
||||
|
||||
get contents () {
|
||||
return this._buff
|
||||
.map(chunk => chunk.toString())
|
||||
.join('');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OutputListener;
|
||||
9
wrapper/lib/terraform-bin.js
Normal file
9
wrapper/lib/terraform-bin.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (() => {
|
||||
// If we're on Windows, then the executable ends with .exe
|
||||
const exeSuffix = os.platform().startsWith('win') ? '.exe' : '';
|
||||
|
||||
return [process.env.TERRAFORM_CLI_PATH, `terraform-bin${exeSuffix}`].join(path.sep);
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue