From 57a8ed74cac0fad50e89830478727dd307f9aaa2 Mon Sep 17 00:00:00 2001 From: Yevhen Fabizhevskyi Date: Thu, 19 Mar 2020 23:22:57 +0900 Subject: [PATCH] Add sudo --- README.md | 2 +- action.yml | 2 +- src/index.js | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7ed4a22..6ca7023 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This action installs one of the brainfuck interpreters called [brainfucky](https://pypi.org/project/brainfucky/). ## Inputs -1. `version` - _[Optional]_ Brainfucky library version. +1. `version` - _[Optional]_ Brainfucky library version. Default is the [latest](https://pypi.org/project/brainfucky/) version. ## Example usage diff --git a/action.yml b/action.yml index 689d17a..364982a 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: version: description: 'Brainfucky library version.' required: false - default: latest + default: null runs: using: 'node12' main: 'src/index.js' diff --git a/src/index.js b/src/index.js index 539fc86..13bfc48 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,12 @@ const core = require('@actions/core'); -const exec = require('@actions/exec'); +const { exec } = require('@actions/exec'); const version = core.getInput('version'); (async () => { try { - await exec.exec('pip install brainfucky' + (!version || version === 'latest' ? '' : `==${version}`)); + const sudo = process.platform !== 'win32' ? 'sudo ' : ''; + await exec(`${sudo}pip install brainfucky` + (version ? `==${version}` : '')); } catch (e) { core.setFailed(e.message); }