Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5548e10

Browse files
committed
fix for multiple imports
1 parent7cc0896 commit5548e10

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-
constimportRegex=/\bimport\s+(?:\s?(.+)\}?\s+from\s+)?[\'"]([^"\']+)["\']/;
1+
constimportRegex=/^import\s+(?:\s?(.+)\}?\s+from\s+)?[\'"]([^"\']+)["\']/;
22
constnamedRegex=/^{.+}$/;
33

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

33-
letoutput='';
33+
letoutput='\n';
3434

3535
for(letkeyinimports){/* 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)

[8]ページ先頭

©2009-2025 Movatter.jp