Skip to content

Commit 85e88a6

Browse files
authored
Merge pull request actions#136 from actions/search-cwd-first
Only search cwd on user-script require calls
2 parents 95fb649 + 5cbb702 commit 85e88a6

File tree

3 files changed

+138
-156
lines changed

3 files changed

+138
-156
lines changed

dist/index.js

+128-142
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports =
4040
/******/ // the startup function
4141
/******/ function startup() {
4242
/******/ // Load entry module and return exports
43-
/******/ return __webpack_require__(720);
43+
/******/ return __webpack_require__(272);
4444
/******/ };
4545
/******/ // initialize runtime
4646
/******/ runtime(__webpack_require__);
@@ -2424,6 +2424,114 @@ exports.request = request;
24242424
//# sourceMappingURL=index.js.map
24252425

24262426

2427+
/***/ }),
2428+
2429+
/***/ 272:
2430+
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
2431+
2432+
"use strict";
2433+
__webpack_require__.r(__webpack_exports__);
2434+
2435+
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
2436+
var core = __webpack_require__(186);
2437+
2438+
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
2439+
var lib_github = __webpack_require__(438);
2440+
2441+
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
2442+
var glob = __webpack_require__(90);
2443+
2444+
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
2445+
var io = __webpack_require__(436);
2446+
2447+
// CONCATENATED MODULE: ./src/async-function.ts
2448+
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor;
2449+
function callAsyncFunction(args, source) {
2450+
const fn = new AsyncFunction(...Object.keys(args), source);
2451+
return fn(...Object.values(args));
2452+
}
2453+
2454+
// EXTERNAL MODULE: external "path"
2455+
var external_path_ = __webpack_require__(622);
2456+
2457+
// CONCATENATED MODULE: ./src/wrap-require.ts
2458+
2459+
const wrapRequire = new Proxy(require, {
2460+
apply: (target, thisArg, [moduleID]) => {
2461+
if (moduleID.startsWith('.')) {
2462+
moduleID = Object(external_path_.resolve)(moduleID);
2463+
return target.apply(thisArg, [moduleID]);
2464+
}
2465+
const modulePath = target.resolve.apply(thisArg, [
2466+
moduleID,
2467+
{
2468+
// Webpack does not have an escape hatch for getting the actual
2469+
// module, other than `eval`.
2470+
paths: [process.cwd()]
2471+
}
2472+
]);
2473+
return target.apply(thisArg, [modulePath]);
2474+
},
2475+
get: (target, prop, receiver) => {
2476+
Reflect.get(target, prop, receiver);
2477+
}
2478+
});
2479+
2480+
// CONCATENATED MODULE: ./src/main.ts
2481+
2482+
2483+
2484+
2485+
2486+
2487+
process.on('unhandledRejection', handleError);
2488+
main().catch(handleError);
2489+
async function main() {
2490+
const token = Object(core.getInput)('github-token', { required: true });
2491+
const debug = Object(core.getInput)('debug');
2492+
const userAgent = Object(core.getInput)('user-agent');
2493+
const previews = Object(core.getInput)('previews');
2494+
const opts = {};
2495+
if (debug === 'true')
2496+
opts.log = console;
2497+
if (userAgent != null)
2498+
opts.userAgent = userAgent;
2499+
if (previews != null)
2500+
opts.previews = previews.split(',');
2501+
const github = Object(lib_github.getOctokit)(token, opts);
2502+
const script = Object(core.getInput)('script', { required: true });
2503+
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
2504+
const result = await callAsyncFunction({
2505+
require: wrapRequire,
2506+
__original_require__: require,
2507+
github,
2508+
context: lib_github.context,
2509+
core: core,
2510+
glob: glob,
2511+
io: io
2512+
}, script);
2513+
let encoding = Object(core.getInput)('result-encoding');
2514+
encoding = encoding ? encoding : 'json';
2515+
let output;
2516+
switch (encoding) {
2517+
case 'json':
2518+
output = JSON.stringify(result);
2519+
break;
2520+
case 'string':
2521+
output = String(result);
2522+
break;
2523+
default:
2524+
throw new Error('"result-encoding" must be either "string" or "json"');
2525+
}
2526+
Object(core.setOutput)('result', output);
2527+
}
2528+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2529+
function handleError(err) {
2530+
console.error(err);
2531+
Object(core.setFailed)(`Unhandled error: ${err}`);
2532+
}
2533+
2534+
24272535
/***/ }),
24282536

24292537
/***/ 278:
@@ -2883,43 +2991,6 @@ function escapeProperty(s) {
28832991

28842992
module.exports = require("assert");
28852993

2886-
/***/ }),
2887-
2888-
/***/ 366:
2889-
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
2890-
2891-
"use strict";
2892-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wrapRequire", function() { return wrapRequire; });
2893-
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(622);
2894-
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
2895-
2896-
const wrapRequire = new Proxy(require, {
2897-
apply: (target, thisArg, [moduleID]) => {
2898-
if (moduleID.startsWith('.')) {
2899-
moduleID = path__WEBPACK_IMPORTED_MODULE_0__.resolve(moduleID);
2900-
return target.apply(thisArg, [moduleID]);
2901-
}
2902-
try {
2903-
return target.apply(thisArg, [moduleID]);
2904-
}
2905-
catch (err) {
2906-
const modulePath = target.resolve.apply(thisArg, [
2907-
moduleID,
2908-
{
2909-
// Webpack does not have an escape hatch for getting the actual
2910-
// module, other than `eval`.
2911-
paths: eval('module').paths.concat(process.cwd())
2912-
}
2913-
]);
2914-
return target.apply(thisArg, [modulePath]);
2915-
}
2916-
},
2917-
get: (target, prop, receiver) => {
2918-
Reflect.get(target, prop, receiver);
2919-
}
2920-
});
2921-
2922-
29232994
/***/ }),
29242995

29252996
/***/ 413:
@@ -6131,91 +6202,6 @@ function issueCommand(command, message) {
61316202
exports.issueCommand = issueCommand;
61326203
//# sourceMappingURL=file-command.js.map
61336204

6134-
/***/ }),
6135-
6136-
/***/ 720:
6137-
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
6138-
6139-
"use strict";
6140-
__webpack_require__.r(__webpack_exports__);
6141-
6142-
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
6143-
var core = __webpack_require__(186);
6144-
6145-
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
6146-
var lib_github = __webpack_require__(438);
6147-
6148-
// EXTERNAL MODULE: ./node_modules/@actions/glob/lib/glob.js
6149-
var glob = __webpack_require__(90);
6150-
6151-
// EXTERNAL MODULE: ./node_modules/@actions/io/lib/io.js
6152-
var io = __webpack_require__(436);
6153-
6154-
// CONCATENATED MODULE: ./src/async-function.ts
6155-
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor;
6156-
function callAsyncFunction(args, source) {
6157-
const fn = new AsyncFunction(...Object.keys(args), source);
6158-
return fn(...Object.values(args));
6159-
}
6160-
6161-
// EXTERNAL MODULE: ./src/wrap-require.ts
6162-
var wrap_require = __webpack_require__(366);
6163-
6164-
// CONCATENATED MODULE: ./src/main.ts
6165-
6166-
6167-
6168-
6169-
6170-
6171-
process.on('unhandledRejection', handleError);
6172-
main().catch(handleError);
6173-
async function main() {
6174-
const token = Object(core.getInput)('github-token', { required: true });
6175-
const debug = Object(core.getInput)('debug');
6176-
const userAgent = Object(core.getInput)('user-agent');
6177-
const previews = Object(core.getInput)('previews');
6178-
const opts = {};
6179-
if (debug === 'true')
6180-
opts.log = console;
6181-
if (userAgent != null)
6182-
opts.userAgent = userAgent;
6183-
if (previews != null)
6184-
opts.previews = previews.split(',');
6185-
const github = Object(lib_github.getOctokit)(token, opts);
6186-
const script = Object(core.getInput)('script', { required: true });
6187-
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
6188-
const result = await callAsyncFunction({
6189-
require: wrap_require.wrapRequire,
6190-
__original_require__: require,
6191-
github,
6192-
context: lib_github.context,
6193-
core: core,
6194-
glob: glob,
6195-
io: io
6196-
}, script);
6197-
let encoding = Object(core.getInput)('result-encoding');
6198-
encoding = encoding ? encoding : 'json';
6199-
let output;
6200-
switch (encoding) {
6201-
case 'json':
6202-
output = JSON.stringify(result);
6203-
break;
6204-
case 'string':
6205-
output = String(result);
6206-
break;
6207-
default:
6208-
throw new Error('"result-encoding" must be either "string" or "json"');
6209-
}
6210-
Object(core.setOutput)('result', output);
6211-
}
6212-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6213-
function handleError(err) {
6214-
console.error(err);
6215-
Object(core.setFailed)(`Unhandled error: ${err}`);
6216-
}
6217-
6218-
62196205
/***/ }),
62206206

62216207
/***/ 747:
@@ -8773,15 +8759,14 @@ function regExpEscape (s) {
87738759
/******/ function(__webpack_require__) { // webpackRuntimeModules
87748760
/******/ "use strict";
87758761
/******/
8776-
/******/ /* webpack/runtime/compat get default export */
8762+
/******/ /* webpack/runtime/make namespace object */
87778763
/******/ !function() {
8778-
/******/ // getDefaultExport function for compatibility with non-harmony modules
8779-
/******/ __webpack_require__.n = function(module) {
8780-
/******/ var getter = module && module.__esModule ?
8781-
/******/ function getDefault() { return module['default']; } :
8782-
/******/ function getModuleExports() { return module; };
8783-
/******/ __webpack_require__.d(getter, 'a', getter);
8784-
/******/ return getter;
8764+
/******/ // define __esModule on exports
8765+
/******/ __webpack_require__.r = function(exports) {
8766+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
8767+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
8768+
/******/ }
8769+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
87858770
/******/ };
87868771
/******/ }();
87878772
/******/
@@ -8796,17 +8781,6 @@ function regExpEscape (s) {
87968781
/******/ };
87978782
/******/ }();
87988783
/******/
8799-
/******/ /* webpack/runtime/make namespace object */
8800-
/******/ !function() {
8801-
/******/ // define __esModule on exports
8802-
/******/ __webpack_require__.r = function(exports) {
8803-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
8804-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
8805-
/******/ }
8806-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
8807-
/******/ };
8808-
/******/ }();
8809-
/******/
88108784
/******/ /* webpack/runtime/create fake namespace object */
88118785
/******/ !function() {
88128786
/******/ // create a fake namespace object
@@ -8826,5 +8800,17 @@ function regExpEscape (s) {
88268800
/******/ };
88278801
/******/ }();
88288802
/******/
8803+
/******/ /* webpack/runtime/compat get default export */
8804+
/******/ !function() {
8805+
/******/ // getDefaultExport function for compatibility with non-harmony modules
8806+
/******/ __webpack_require__.n = function(module) {
8807+
/******/ var getter = module && module.__esModule ?
8808+
/******/ function getDefault() { return module['default']; } :
8809+
/******/ function getModuleExports() { return module; };
8810+
/******/ __webpack_require__.d(getter, 'a', getter);
8811+
/******/ return getter;
8812+
/******/ };
8813+
/******/ }();
8814+
/******/
88298815
/******/ }
88308816
);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "github-script",
33
"description": "A GitHub action for executing a simple script",
4-
"version": "4.0.0",
4+
"version": "4.0.1",
55
"author": "GitHub",
66
"license": "MIT",
77
"main": "dist/index.js",

src/wrap-require.ts

+9-13
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ export const wrapRequire = new Proxy(__non_webpack_require__, {
77
return target.apply(thisArg, [moduleID])
88
}
99

10-
try {
11-
return target.apply(thisArg, [moduleID])
12-
} catch (err) {
13-
const modulePath = target.resolve.apply(thisArg, [
14-
moduleID,
15-
{
16-
// Webpack does not have an escape hatch for getting the actual
17-
// module, other than `eval`.
18-
paths: eval('module').paths.concat(process.cwd())
19-
}
20-
])
10+
const modulePath = target.resolve.apply(thisArg, [
11+
moduleID,
12+
{
13+
// Webpack does not have an escape hatch for getting the actual
14+
// module, other than `eval`.
15+
paths: [process.cwd()]
16+
}
17+
])
2118

22-
return target.apply(thisArg, [modulePath])
23-
}
19+
return target.apply(thisArg, [modulePath])
2420
},
2521

2622
get: (target, prop, receiver) => {

0 commit comments

Comments
 (0)