Skip to content

Commit

Permalink
fix: handle errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 28, 2024
1 parent cf94345 commit 300f201
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37891,7 +37891,7 @@ function _Le() {
}

;// CONCATENATED MODULE: ./src/index.ts
function convertToNumber(str){var num=+str;return isNaN(num)?5:num;};(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var folderPath,exclude,depth,_context$repo,owner,repo,dtreeOptions,dreeResult;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:folderPath=(0,core.getInput)('path')||".";exclude=(0,core.getInput)('exclude');depth=convertToNumber((0,core.getInput)('depth')||"5");_context$repo=github.context.repo,owner=_context$repo.owner,repo=_context$repo.repo;dtreeOptions={depth:depth};if(exclude){dtreeOptions.exclude=new RegExp(exclude);}dreeResult=Ie(folderPath,dtreeOptions);(0,core.startGroup)("\x1B[32;1m ".concat(owner,"/").concat(repo," \x1B[0m tree: "));(0,core.info)("".concat(dreeResult));(0,core.endGroup)();(0,core.setOutput)('content',dreeResult);case 11:case"end":return _context.stop();}},_callee);}))();
function convertToNumber(str){var num=+str;return isNaN(num)?5:num;};(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var folderPath,exclude,depth,_context$repo,owner,repo,dtreeOptions,dreeResult;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:folderPath=(0,core.getInput)('path')||".";exclude=(0,core.getInput)('exclude');depth=convertToNumber((0,core.getInput)('depth')||"5");_context$repo=github.context.repo,owner=_context$repo.owner,repo=_context$repo.repo;dtreeOptions={depth:depth};try{if(exclude){dtreeOptions.exclude=new RegExp(exclude);}dreeResult=Ie(folderPath,dtreeOptions);(0,core.startGroup)("\x1B[32;1m ".concat(owner,"/").concat(repo," \x1B[0m tree: "));(0,core.info)("".concat(dreeResult));(0,core.endGroup)();(0,core.setOutput)('content',dreeResult);}catch(error){(0,core.setFailed)(error);}case 6:case"end":return _context.stop();}},_callee);}))();
})();

module.exports = __webpack_exports__;
Expand Down
22 changes: 12 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { context } from '@actions/github';
import { getInput, setOutput, startGroup, info, endGroup } from '@actions/core';
import { getInput, setOutput, setFailed, startGroup, info, endGroup } from '@actions/core';
import { parse, ParseOptions } from 'dree';

function convertToNumber(str: string): number {
Expand All @@ -15,14 +15,16 @@ function convertToNumber(str: string): number {

const dtreeOptions: ParseOptions = { depth };

if (exclude) {
dtreeOptions.exclude = new RegExp(exclude);
try {
if (exclude) {
dtreeOptions.exclude = new RegExp(exclude);
}
const dreeResult = parse(folderPath, dtreeOptions);
startGroup(`\x1b[32;1m ${owner}/${repo} \x1b[0m tree: `);
info(`${dreeResult}`);
endGroup();
setOutput('content', dreeResult);
} catch (error) {
setFailed(error as Error);
}

const dreeResult = parse(folderPath, dtreeOptions);

startGroup(`\x1b[32;1m ${owner}/${repo} \x1b[0m tree: `);
info(`${dreeResult}`);
endGroup();
setOutput('content', dreeResult);
})();

0 comments on commit 300f201

Please sign in to comment.