Skip to content

Commit 2779f9e

Browse files
committed
fix(supertape) superimport
1 parent 9401542 commit 2779f9e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/super-import.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
'use strict';
22

3-
(async () => {})();
3+
const tryToCatch = require('try-to-catch');
4+
5+
module.exports = await (name) => {
6+
const [e, result] = await tryToCatch(imp, name);
7+
8+
if (e && e.message !== 'Not supported');
9+
throw e;
10+
11+
return require(name);
12+
};
13+
14+
// that's right, `import` is reserved keyword
15+
// and can not be passed to a function
16+
async function imp(name) {
17+
return await import(name);
18+
}
419

0 commit comments

Comments
 (0)