diff --git a/__test__/input-helper.unit.test.ts b/__test__/input-helper.unit.test.ts deleted file mode 100644 index 6355509..0000000 --- a/__test__/input-helper.unit.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {getInputs} from '../src/input-helper' - -describe('input-helper tests', () => { - const ORIGINAL_ENV = process.env - - beforeEach(() => { - jest.resetModules() - process.env = {...ORIGINAL_ENV} - }) - - afterAll(() => { - process.env = ORIGINAL_ENV - }) - - test('enableUrlCompletion should be false when "false" is passed', () => { - process.env['INPUT_ENABLE-URL-COMPLETION'] = 'false' - - const inputs = getInputs() - expect(inputs.enableUrlCompletion).toBe(false) - }) - - test('enableUrlCompletion should be true when "true" is passed', () => { - process.env['INPUT_ENABLE-URL-COMPLETION'] = 'true' - - const inputs = getInputs() - expect(inputs.enableUrlCompletion).toBe(true) - }) -}) diff --git a/action.yml b/action.yml index 878d62e..9899483 100644 --- a/action.yml +++ b/action.yml @@ -22,7 +22,6 @@ inputs: description: > Enables completion of relative URLs to absolute ones Default: `false` - default: "false" image-extensions: description: > File extensions that will be treated as images diff --git a/dist/index.js b/dist/index.js index 5c93eb7..b66d398 100644 --- a/dist/index.js +++ b/dist/index.js @@ -128,7 +128,7 @@ function getInputs() { repository: core.getInput('repository'), shortDescription: core.getInput('short-description'), readmeFilepath: core.getInput('readme-filepath'), - enableUrlCompletion: core.getBooleanInput('enable-url-completion'), + enableUrlCompletion: Boolean(core.getInput('enable-url-completion')), imageExtensions: core.getInput('image-extensions') }; // Environment variable input alternatives and their aliases @@ -157,8 +157,7 @@ function getInputs() { inputs.readmeFilepath = process.env['README_FILEPATH']; } if (!inputs.enableUrlCompletion && process.env['ENABLE_URL_COMPLETION']) { - inputs.enableUrlCompletion = - process.env['ENABLE_URL_COMPLETION'].toLowerCase() === 'true'; + inputs.enableUrlCompletion = Boolean(process.env['ENABLE_URL_COMPLETION']); } if (!inputs.imageExtensions && process.env['IMAGE_EXTENSIONS']) { inputs.imageExtensions = process.env['IMAGE_EXTENSIONS']; @@ -167,6 +166,9 @@ function getInputs() { if (!inputs.readmeFilepath) { inputs.readmeFilepath = readmeHelper.README_FILEPATH_DEFAULT; } + if (!inputs.enableUrlCompletion) { + inputs.enableUrlCompletion = readmeHelper.ENABLE_URL_COMPLETION_DEFAULT; + } if (!inputs.imageExtensions) { inputs.imageExtensions = readmeHelper.IMAGE_EXTENSIONS_DEFAULT; } @@ -311,12 +313,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.completeRelativeUrls = exports.getReadmeContent = exports.IMAGE_EXTENSIONS_DEFAULT = exports.README_FILEPATH_DEFAULT = void 0; +exports.completeRelativeUrls = exports.getReadmeContent = exports.ENABLE_URL_COMPLETION_DEFAULT = exports.IMAGE_EXTENSIONS_DEFAULT = exports.README_FILEPATH_DEFAULT = void 0; const core = __importStar(__nccwpck_require__(7484)); const fs = __importStar(__nccwpck_require__(9896)); const utils = __importStar(__nccwpck_require__(9277)); exports.README_FILEPATH_DEFAULT = './README.md'; exports.IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp'; +exports.ENABLE_URL_COMPLETION_DEFAULT = false; const TITLE_REGEX = `(?: +"[^"]+")?`; const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}`; const BLOB_PREFIX = `${REPOSITORY_URL}/blob/${process.env['GITHUB_REF_NAME']}/`; diff --git a/src/input-helper.ts b/src/input-helper.ts index 0f31920..7093ee3 100644 --- a/src/input-helper.ts +++ b/src/input-helper.ts @@ -18,7 +18,7 @@ export function getInputs(): Inputs { repository: core.getInput('repository'), shortDescription: core.getInput('short-description'), readmeFilepath: core.getInput('readme-filepath'), - enableUrlCompletion: core.getBooleanInput('enable-url-completion'), + enableUrlCompletion: Boolean(core.getInput('enable-url-completion')), imageExtensions: core.getInput('image-extensions') } @@ -54,8 +54,7 @@ export function getInputs(): Inputs { } if (!inputs.enableUrlCompletion && process.env['ENABLE_URL_COMPLETION']) { - inputs.enableUrlCompletion = - process.env['ENABLE_URL_COMPLETION'].toLowerCase() === 'true' + inputs.enableUrlCompletion = Boolean(process.env['ENABLE_URL_COMPLETION']) } if (!inputs.imageExtensions && process.env['IMAGE_EXTENSIONS']) { @@ -66,6 +65,9 @@ export function getInputs(): Inputs { if (!inputs.readmeFilepath) { inputs.readmeFilepath = readmeHelper.README_FILEPATH_DEFAULT } + if (!inputs.enableUrlCompletion) { + inputs.enableUrlCompletion = readmeHelper.ENABLE_URL_COMPLETION_DEFAULT + } if (!inputs.imageExtensions) { inputs.imageExtensions = readmeHelper.IMAGE_EXTENSIONS_DEFAULT } diff --git a/src/readme-helper.ts b/src/readme-helper.ts index f7e381e..90075c4 100644 --- a/src/readme-helper.ts +++ b/src/readme-helper.ts @@ -4,6 +4,7 @@ import * as utils from './utils' export const README_FILEPATH_DEFAULT = './README.md' export const IMAGE_EXTENSIONS_DEFAULT = 'bmp,gif,jpg,jpeg,png,svg,webp' +export const ENABLE_URL_COMPLETION_DEFAULT = false const TITLE_REGEX = `(?: +"[^"]+")?` const REPOSITORY_URL = `${process.env['GITHUB_SERVER_URL']}/${process.env['GITHUB_REPOSITORY']}`