mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 05:14:44 +00:00
.
This commit is contained in:
parent
a004f0ae58
commit
fc725ba36b
7280 changed files with 19 additions and 1796407 deletions
331
node_modules/stack-utils/index.js
generated
vendored
331
node_modules/stack-utils/index.js
generated
vendored
|
@ -1,331 +0,0 @@
|
|||
'use strict';
|
||||
module.exports = StackUtils;
|
||||
|
||||
function StackUtils(opts) {
|
||||
if (!(this instanceof StackUtils)) {
|
||||
throw new Error('StackUtils constructor must be called with new');
|
||||
}
|
||||
opts = opts || {};
|
||||
this._cwd = (opts.cwd || process.cwd()).replace(/\\/g, '/');
|
||||
this._internals = opts.internals || [];
|
||||
this._wrapCallSite = opts.wrapCallSite || false;
|
||||
}
|
||||
|
||||
module.exports.nodeInternals = nodeInternals;
|
||||
|
||||
function nodeInternals() {
|
||||
if (!module.exports.natives) {
|
||||
module.exports.natives = Object.keys(process.binding('natives'));
|
||||
module.exports.natives.push('bootstrap_node', 'node',
|
||||
'internal/bootstrap/node');
|
||||
}
|
||||
|
||||
return module.exports.natives.map(function (n) {
|
||||
return new RegExp('\\(' + n + '\\.js:\\d+:\\d+\\)$');
|
||||
}).concat([
|
||||
/\s*at (bootstrap_)?node\.js:\d+:\d+?$/,
|
||||
/\(internal\/[^:]+:\d+:\d+\)$/,
|
||||
/\/\.node-spawn-wrap-\w+-\w+\/node:\d+:\d+\)?$/
|
||||
]);
|
||||
}
|
||||
|
||||
StackUtils.prototype.clean = function (stack) {
|
||||
if (!Array.isArray(stack)) {
|
||||
stack = stack.split('\n');
|
||||
}
|
||||
|
||||
if (!(/^\s*at /.test(stack[0])) &&
|
||||
(/^\s*at /.test(stack[1]))) {
|
||||
stack = stack.slice(1);
|
||||
}
|
||||
|
||||
var outdent = false;
|
||||
var lastNonAtLine = null;
|
||||
var result = [];
|
||||
|
||||
stack.forEach(function (st) {
|
||||
st = st.replace(/\\/g, '/');
|
||||
var isInternal = this._internals.some(function (internal) {
|
||||
return internal.test(st);
|
||||
});
|
||||
|
||||
if (isInternal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var isAtLine = /^\s*at /.test(st);
|
||||
|
||||
if (outdent) {
|
||||
st = st.replace(/\s+$/, '').replace(/^(\s+)at /, '$1');
|
||||
} else {
|
||||
st = st.trim();
|
||||
if (isAtLine) {
|
||||
st = st.substring(3);
|
||||
}
|
||||
}
|
||||
|
||||
st = st.replace(this._cwd + '/', '');
|
||||
|
||||
if (st) {
|
||||
if (isAtLine) {
|
||||
if (lastNonAtLine) {
|
||||
result.push(lastNonAtLine);
|
||||
lastNonAtLine = null;
|
||||
}
|
||||
result.push(st);
|
||||
} else {
|
||||
outdent = true;
|
||||
lastNonAtLine = st;
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
stack = result.join('\n').trim();
|
||||
|
||||
if (stack) {
|
||||
return stack + '\n';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
StackUtils.prototype.captureString = function (limit, fn) {
|
||||
if (typeof limit === 'function') {
|
||||
fn = limit;
|
||||
limit = Infinity;
|
||||
}
|
||||
if (!fn) {
|
||||
fn = this.captureString;
|
||||
}
|
||||
|
||||
var limitBefore = Error.stackTraceLimit;
|
||||
if (limit) {
|
||||
Error.stackTraceLimit = limit;
|
||||
}
|
||||
|
||||
var obj = {};
|
||||
|
||||
Error.captureStackTrace(obj, fn);
|
||||
var stack = obj.stack;
|
||||
Error.stackTraceLimit = limitBefore;
|
||||
|
||||
return this.clean(stack);
|
||||
};
|
||||
|
||||
StackUtils.prototype.capture = function (limit, fn) {
|
||||
if (typeof limit === 'function') {
|
||||
fn = limit;
|
||||
limit = Infinity;
|
||||
}
|
||||
if (!fn) {
|
||||
fn = this.capture;
|
||||
}
|
||||
var prepBefore = Error.prepareStackTrace;
|
||||
var limitBefore = Error.stackTraceLimit;
|
||||
var wrapCallSite = this._wrapCallSite;
|
||||
|
||||
Error.prepareStackTrace = function (obj, site) {
|
||||
if (wrapCallSite) {
|
||||
return site.map(wrapCallSite);
|
||||
}
|
||||
return site;
|
||||
};
|
||||
|
||||
if (limit) {
|
||||
Error.stackTraceLimit = limit;
|
||||
}
|
||||
|
||||
var obj = {};
|
||||
Error.captureStackTrace(obj, fn);
|
||||
var stack = obj.stack;
|
||||
Error.prepareStackTrace = prepBefore;
|
||||
Error.stackTraceLimit = limitBefore;
|
||||
|
||||
return stack;
|
||||
};
|
||||
|
||||
StackUtils.prototype.at = function at(fn) {
|
||||
if (!fn) {
|
||||
fn = at;
|
||||
}
|
||||
|
||||
var site = this.capture(1, fn)[0];
|
||||
|
||||
if (!site) {
|
||||
return {};
|
||||
}
|
||||
|
||||
var res = {
|
||||
line: site.getLineNumber(),
|
||||
column: site.getColumnNumber()
|
||||
};
|
||||
|
||||
this._setFile(res, site.getFileName());
|
||||
|
||||
if (site.isConstructor()) {
|
||||
res.constructor = true;
|
||||
}
|
||||
|
||||
if (site.isEval()) {
|
||||
res.evalOrigin = site.getEvalOrigin();
|
||||
}
|
||||
|
||||
// Node v10 stopped with the isNative() on callsites, apparently
|
||||
/* istanbul ignore next */
|
||||
if (site.isNative()) {
|
||||
res.native = true;
|
||||
}
|
||||
|
||||
var typename = null;
|
||||
try {
|
||||
typename = site.getTypeName();
|
||||
} catch (er) {}
|
||||
|
||||
if (typename &&
|
||||
typename !== 'Object' &&
|
||||
typename !== '[object Object]') {
|
||||
res.type = typename;
|
||||
}
|
||||
|
||||
var fname = site.getFunctionName();
|
||||
if (fname) {
|
||||
res.function = fname;
|
||||
}
|
||||
|
||||
var meth = site.getMethodName();
|
||||
if (meth && fname !== meth) {
|
||||
res.method = meth;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
StackUtils.prototype._setFile = function (result, filename) {
|
||||
if (filename) {
|
||||
filename = filename.replace(/\\/g, '/');
|
||||
if ((filename.indexOf(this._cwd + '/') === 0)) {
|
||||
filename = filename.substr(this._cwd.length + 1);
|
||||
}
|
||||
result.file = filename;
|
||||
}
|
||||
};
|
||||
|
||||
var re = new RegExp(
|
||||
'^' +
|
||||
// Sometimes we strip out the ' at' because it's noisy
|
||||
'(?:\\s*at )?' +
|
||||
// $1 = ctor if 'new'
|
||||
'(?:(new) )?' +
|
||||
// $2 = function name (can be literally anything)
|
||||
// May contain method at the end as [as xyz]
|
||||
'(?:(.*?) \\()?' +
|
||||
// (eval at <anonymous> (file.js:1:1),
|
||||
// $3 = eval origin
|
||||
// $4:$5:$6 are eval file/line/col, but not normally reported
|
||||
'(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' +
|
||||
// file:line:col
|
||||
// $7:$8:$9
|
||||
// $10 = 'native' if native
|
||||
'(?:(.+?):(\\d+):(\\d+)|(native))' +
|
||||
// maybe close the paren, then end
|
||||
// if $11 is ), then we only allow balanced parens in the filename
|
||||
// any imbalance is placed on the fname. This is a heuristic, and
|
||||
// bound to be incorrect in some edge cases. The bet is that
|
||||
// having weird characters in method names is more common than
|
||||
// having weird characters in filenames, which seems reasonable.
|
||||
'(\\)?)$'
|
||||
);
|
||||
|
||||
var methodRe = /^(.*?) \[as (.*?)\]$/;
|
||||
|
||||
StackUtils.prototype.parseLine = function parseLine(line) {
|
||||
var match = line && line.match(re);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ctor = match[1] === 'new';
|
||||
var fname = match[2];
|
||||
var evalOrigin = match[3];
|
||||
var evalFile = match[4];
|
||||
var evalLine = Number(match[5]);
|
||||
var evalCol = Number(match[6]);
|
||||
var file = match[7];
|
||||
var lnum = match[8];
|
||||
var col = match[9];
|
||||
var native = match[10] === 'native';
|
||||
var closeParen = match[11] === ')';
|
||||
|
||||
var res = {};
|
||||
|
||||
if (lnum) {
|
||||
res.line = Number(lnum);
|
||||
}
|
||||
|
||||
if (col) {
|
||||
res.column = Number(col);
|
||||
}
|
||||
|
||||
if (closeParen && file) {
|
||||
// make sure parens are balanced
|
||||
// if we have a file like "asdf) [as foo] (xyz.js", then odds are
|
||||
// that the fname should be += " (asdf) [as foo]" and the file
|
||||
// should be just "xyz.js"
|
||||
// walk backwards from the end to find the last unbalanced (
|
||||
var closes = 0;
|
||||
for (var i = file.length - 1; i > 0; i--) {
|
||||
if (file.charAt(i) === ')') {
|
||||
closes ++;
|
||||
} else if (file.charAt(i) === '(' && file.charAt(i - 1) === ' ') {
|
||||
closes --;
|
||||
if (closes === -1 && file.charAt(i - 1) === ' ') {
|
||||
var before = file.substr(0, i - 1);
|
||||
var after = file.substr(i + 1);
|
||||
file = after;
|
||||
fname += ' (' + before;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fname) {
|
||||
var methodMatch = fname.match(methodRe);
|
||||
if (methodMatch) {
|
||||
fname = methodMatch[1];
|
||||
var meth = methodMatch[2];
|
||||
}
|
||||
}
|
||||
|
||||
this._setFile(res, file);
|
||||
|
||||
if (ctor) {
|
||||
res.constructor = true;
|
||||
}
|
||||
|
||||
if (evalOrigin) {
|
||||
res.evalOrigin = evalOrigin;
|
||||
res.evalLine = evalLine;
|
||||
res.evalColumn = evalCol;
|
||||
res.evalFile = evalFile && evalFile.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
if (native) {
|
||||
res.native = true;
|
||||
}
|
||||
|
||||
if (fname) {
|
||||
res.function = fname;
|
||||
}
|
||||
|
||||
if (meth && fname !== meth) {
|
||||
res.method = meth;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
var bound = new StackUtils();
|
||||
|
||||
Object.keys(StackUtils.prototype).forEach(function (key) {
|
||||
StackUtils[key] = bound[key].bind(bound);
|
||||
});
|
23
node_modules/stack-utils/license
generated
vendored
23
node_modules/stack-utils/license
generated
vendored
|
@ -1,23 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter <i@izs.me>, James Talmage <james@talmage.io> (github.com/jamestalmage), and Contributors
|
||||
|
||||
Extracted from code in node-tap http://www.node-tap.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
72
node_modules/stack-utils/package.json
generated
vendored
72
node_modules/stack-utils/package.json
generated
vendored
|
@ -1,72 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"stack-utils@1.0.2",
|
||||
"/Users/eric/repos/actions/setup-node"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "stack-utils@1.0.2",
|
||||
"_id": "stack-utils@1.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-MTX+MeG5U994cazkjd/9KNAapsHnibjMLnfXodlkXw76JEea0UiNzrqidzo1emMwk7w5Qhc9jd4Bn9TBb1MFwA==",
|
||||
"_location": "/stack-utils",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "stack-utils@1.0.2",
|
||||
"name": "stack-utils",
|
||||
"escapedName": "stack-utils",
|
||||
"rawSpec": "1.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jest-circus",
|
||||
"/jest-message-util"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.2.tgz",
|
||||
"_spec": "1.0.2",
|
||||
"_where": "/Users/eric/repos/actions/setup-node",
|
||||
"author": {
|
||||
"name": "James Talmage",
|
||||
"email": "james@talmage.io",
|
||||
"url": "github.com/jamestalmage"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tapjs/stack-utils/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Captures and cleans stack traces",
|
||||
"devDependencies": {
|
||||
"bluebird": "^3.1.1",
|
||||
"coveralls": "^2.11.6",
|
||||
"flatten": "0.0.1",
|
||||
"nested-error-stacks": "^2.0.0",
|
||||
"pify": "^2.3.0",
|
||||
"q": "^1.4.1",
|
||||
"tap": "^10.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/tapjs/stack-utils#readme",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"name": "stack-utils",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tapjs/stack-utils.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"test": "tap test/*.js --100 -J"
|
||||
},
|
||||
"version": "1.0.2"
|
||||
}
|
132
node_modules/stack-utils/readme.md
generated
vendored
132
node_modules/stack-utils/readme.md
generated
vendored
|
@ -1,132 +0,0 @@
|
|||
# stack-utils
|
||||
|
||||
> Captures and cleans stack traces.
|
||||
|
||||
[](https://travis-ci.org/tapjs/stack-utils) [](https://ci.appveyor.com/project/jamestalmage/stack-utils-oiw96/branch/master) [](https://coveralls.io/github/tapjs/stack-utils?branch=master)
|
||||
|
||||
|
||||
Extracted from `lib/stack.js` in the [`node-tap` project](https://github.com/tapjs/node-tap)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save stack-utils
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const StackUtils = require('stack-utils');
|
||||
const stack = new StackUtils({cwd: process.cwd(), internals: StackUtils.nodeInternals()});
|
||||
|
||||
console.log(stack.clean(new Error().stack));
|
||||
// outputs a beautified stack trace
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
|
||||
### new StackUtils([options])
|
||||
|
||||
Creates a new `stackUtils` instance.
|
||||
|
||||
#### options
|
||||
|
||||
##### internals
|
||||
|
||||
Type: `array` of `RegularExpression`s
|
||||
|
||||
A set of regular expressions that match internal stack stack trace lines which should be culled from the stack trace.
|
||||
`StackUtils.nodeInternals()` returns a relatively set of sensible defaults for use on the node platform.
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`
|
||||
|
||||
The path to the current working directory. File names in the stack trace will be shown relative to this directory.
|
||||
|
||||
##### wrapCallSite
|
||||
|
||||
Type: `function(CallSite)`
|
||||
|
||||
A mapping function for manipulating CallSites before processing. The first argument is a CallSite instance, and the function should return a modified CallSite. This is useful for providing source map support.
|
||||
|
||||
|
||||
### StackUtils.nodeInternals()
|
||||
|
||||
Returns an array of regular expressions that be used to cull lines from the stack trace that reference common Node.js internal files.
|
||||
|
||||
|
||||
### stackUtils.clean(stack)
|
||||
|
||||
Cleans up a stack trace by deleting any lines that match the `internals` passed to the constructor, and shortening file names relative to `cwd`.
|
||||
|
||||
Returns a `string` with the cleaned up stack (always terminated with a `\n` newline character).
|
||||
|
||||
#### stack
|
||||
|
||||
*Required*
|
||||
Type: `string` or an `array` of `string`s
|
||||
|
||||
|
||||
### stackUtils.capture([limit], [startStackFunction])
|
||||
|
||||
Captures the current stack trace, returning an array of `CallSite`s. There are good overviews of the available CallSite methods [here](https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces), and [here](https://github.com/sindresorhus/callsites#api).
|
||||
|
||||
#### limit
|
||||
|
||||
Type: `number`
|
||||
Default: `Infinity`
|
||||
|
||||
Limits the number of lines returned by dropping all lines in excess of the limit. This removes lines from the stack trace.
|
||||
|
||||
#### startStackFunction
|
||||
|
||||
Type: `function`
|
||||
|
||||
The function where the stack trace should start. The first line of the stack trace will be the function that called `startStackFunction`. This removes lines from the end of the stack trace.
|
||||
|
||||
|
||||
### stackUtils.captureString([limit], [startStackFunction])
|
||||
|
||||
Captures the current stack trace, cleans it using `stackUtils.clean(stack)`, and returns a string with the cleaned stack trace. It takes the same arguments as `stackUtils.capture`.
|
||||
|
||||
|
||||
### stackUtils.at([startStackFunction])
|
||||
|
||||
Captures the first line of the stack trace (or the first line after `startStackFunction` if supplied), and returns a `CallSite` like object that is serialization friendly (properties are actual values instead of getter functions).
|
||||
|
||||
The available properties are:
|
||||
|
||||
- `line`: `number`
|
||||
- `column`: `number`
|
||||
- `file`: `string`
|
||||
- `constructor`: `boolean`
|
||||
- `evalOrigin`: `string`
|
||||
- `native`: `boolean`
|
||||
- `typename`: `string`
|
||||
- `function`: `string`
|
||||
- `method`: `string`
|
||||
|
||||
### stackUtils.parseLine(line)
|
||||
|
||||
Parses a `string` (which should be a single line from a stack trace), and generates an object with the following properties:
|
||||
|
||||
- `line`: `number`
|
||||
- `column`: `number`
|
||||
- `file`: `string`
|
||||
- `constructor`: `boolean`
|
||||
- `evalOrigin`: `string`
|
||||
- `evalLine`: `number`
|
||||
- `evalColumn`: `number`
|
||||
- `evalFile`: `string`
|
||||
- `native`: `boolean`
|
||||
- `function`: `string`
|
||||
- `method`: `string`
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Isaac Z. Schlueter](http://github.com/isaacs), [James Talmage](http://github.com/jamestalmage)
|
Loading…
Add table
Add a link
Reference in a new issue