Skip to content

Commit 5548e10

Browse files
committed
fix for multiple imports
1 parent 7cc0896 commit 5548e10

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/addImportsAsVars.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const importRegex = /\bimport\s+(?:\s?(.+)\}?\s+from\s+)?[\'"]([^"\']+)["\']/;
1+
const importRegex = /^import\s+(?:\s?(.+)\}?\s+from\s+)?[\'"]([^"\']+)["\']/;
22
const namedRegex = /^{.+}$/;
33

44
let imports = {};
@@ -30,7 +30,7 @@ function detectImports(src) {
3030
}
3131
});
3232

33-
let output = '';
33+
let output = '\n';
3434

3535
for (let key in imports) { /* jshint forin: false */
3636

@@ -39,9 +39,9 @@ function detectImports(src) {
3939
const { path, importType } = imports[key];
4040
// eval(`var ${key};`);
4141
if (importType === 'named') {
42-
output += `global.${key} = require('${path}').${key};`;
42+
output += `global.${key} = require('${path}').${key};\n`;
4343
} else {
44-
output += `global.${key} = require('${path}')`;
44+
output += `global.${key} = require('${path}');\n`;
4545
}
4646

4747
} catch(e) {}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rewire-coderoad",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "CodeRoad implementation to override 'require' in order to monkey-patch test globals",
55
"keywords": [
66
"dependency",
@@ -30,7 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"expect.js": "^0.3.1",
33-
"mocha": "^2.1.0"
33+
"mocha": "^3.0.2"
3434
},
3535
"license": "MIT",
3636
"scripts": {

0 commit comments

Comments
 (0)