Correctly validate gomodpath (#19)

* Correctly validate go mod path

* add a reasonable default

* preserve required expectation instead

* regenerate the JS
This commit is contained in:
Brandyn Phelps
2022-06-27 09:39:49 -07:00
committed by GitHub
parent a255b6740c
commit b73c5b4dd8
3 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -50,8 +50,8 @@ const dependency_submission_toolkit_1 = __nccwpck_require__(9810);
const process_1 = __nccwpck_require__(4077);
function main() {
return __awaiter(this, void 0, void 0, function* () {
const goModPath = path_1.default.normalize(core.getInput('go-mod-path'));
if (path_1.default.basename(goModPath) !== 'go.mod' && fs_1.default.existsSync(goModPath)) {
const goModPath = path_1.default.normalize(core.getInput('go-mod-path', { required: true }));
if (path_1.default.basename(goModPath) !== 'go.mod' || !fs_1.default.existsSync(goModPath)) {
throw new Error(`${goModPath} is not a go.mod file or does not exist!`);
}
const goModDir = path_1.default.dirname(goModPath);
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -16,9 +16,11 @@ import {
} from './process'
async function main () {
const goModPath = path.normalize(core.getInput('go-mod-path'))
const goModPath = path.normalize(
core.getInput('go-mod-path', { required: true })
)
if (path.basename(goModPath) !== 'go.mod' && fs.existsSync(goModPath)) {
if (path.basename(goModPath) !== 'go.mod' || !fs.existsSync(goModPath)) {
throw new Error(`${goModPath} is not a go.mod file or does not exist!`)
}
const goModDir = path.dirname(goModPath)