Skip to content

Commit eced88a

Browse files
committed
add lib/ for sensen
1 parent 63a7478 commit eced88a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
2-
lib
32
.tern-port
43
npm-debug.log

lib/index.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
exports.default = function (_ref) {
8+
var t = _ref.types;
9+
10+
return {
11+
visitor: {
12+
Program: function Program(path, file) {
13+
// Inject `var CatchPromise = require('catch-promise');`
14+
var catchPromiseDeclaration = t.variableDeclaration('var', [t.variableDeclarator(t.identifier('CatchPromise'), t.callExpression(t.identifier('require'), [t.stringLiteral('catch-promise')]))]);
15+
path.unshiftContainer('body', catchPromiseDeclaration);
16+
},
17+
Identifier: function Identifier(path) {
18+
// Replace `Promise` with `CatchPromise`
19+
if (path.node.name === 'Promise') {
20+
path.replaceWith(t.identifier('CatchPromise'));
21+
}
22+
}
23+
}
24+
};
25+
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "babel-plugin-transform-catch-promise",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "",
55
"main": "lib/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)