aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@ava/babel-plugin-throws-helper/index.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-03-27 21:01:33 +0100
commitcc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch)
tree92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/@ava/babel-plugin-throws-helper/index.js
parent3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff)
remove node_modules
Diffstat (limited to 'node_modules/@ava/babel-plugin-throws-helper/index.js')
-rw-r--r--node_modules/@ava/babel-plugin-throws-helper/index.js70
1 files changed, 0 insertions, 70 deletions
diff --git a/node_modules/@ava/babel-plugin-throws-helper/index.js b/node_modules/@ava/babel-plugin-throws-helper/index.js
deleted file mode 100644
index e370480f1..000000000
--- a/node_modules/@ava/babel-plugin-throws-helper/index.js
+++ /dev/null
@@ -1,70 +0,0 @@
-'use strict';
-
-module.exports = babelCore => {
- const t = babelCore.types;
- const wrapArg = babelCore.template('(START(t, ASSERTION, FILE, LINE), END(t, ARG))');
- const helpers = babelCore.template(`function START(t, assertion, file, line) {
- if (t._throwsArgStart) {
- t._throwsArgStart(assertion, file, line);
- }
-}
-
-function END(t, arg) {
- if (t._throwsArgEnd) {
- t._throwsArgEnd();
- }
-
- return arg;
-}`);
-
- const assertionVisitor = {
- CallExpression(path, state) {
- const callee = path.get('callee');
- if (!callee.isMemberExpression() || !callee.get('object').isIdentifier({name: 't'}) || !callee.get('property').isIdentifier()) {
- return;
- }
-
- const assertion = callee.get('property').get('name').node;
- if (assertion !== 'throws' && assertion !== 'notThrows') {
- return;
- }
-
- const arg0 = path.node.arguments[0];
- if (!(arg0 && arg0.loc && (typeof arg0.start === 'number') && (typeof arg0.end === 'number'))) {
- return;
- }
-
- // Wrap the argument expression, so that the stack trace of the assertion
- // isn't affected.
- path.node.arguments[0] = wrapArg(Object.assign({
- ARG: arg0,
- ASSERTION: t.stringLiteral(assertion),
- FILE: t.stringLiteral(state.file.opts.filename),
- LINE: t.numericLiteral(arg0.loc.start.line)
- }, this.installHelper())).expression;
- }
- };
-
- return {
- visitor: {
- Program(path, state) {
- const START = t.identifier(path.scope.generateUid('avaThrowsHelperStart'));
- const END = t.identifier(path.scope.generateUid('avaThrowsHelperEnd'));
- const helperIdentifiers = {START, END};
-
- let created = false;
- path.traverse(assertionVisitor, {
- installHelper() {
- if (!created) {
- created = true;
- path.unshiftContainer('body', helpers(helperIdentifiers));
- }
-
- return helperIdentifiers;
- },
- file: state.file
- });
- }
- }
- };
-};