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

Commit84efafe

Browse files
committed
file path bug fixes
1 parent4c5eea3 commit84efafe

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

‎lib/getImportGlobalsSrc.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@
1010
*/
1111
constignore=['global','root','process','Buffer','clearImmediate','clearInterval','setTimeout','module','exports','require'];
1212

13-
functiongetImportGlobalsSrc(ignore){
14-
varkey,
15-
value,
16-
src='',
17-
globalObj=typeofglobal==='undefined' ?window :global;
13+
functiongetImportGlobalsSrc(){
14+
varkey,
15+
value,
16+
src='\n',
17+
globalObj=typeofglobal==='undefined' ?window :global;
1818

19-
for(keyinglobalObj){/* jshint forin: false */
20-
if(ignore.indexOf(key)!==-1){
21-
continue;
22-
}
23-
// value = globalObj[key];
24-
25-
// key may be an invalid variable name (e.g. 'a-b')
26-
try{
27-
// eval('var ' + key);
28-
src+=`var${key} = global.${key}`;
29-
}catch(e){}
19+
for(keyinglobalObj){/* jshint forin: false */
20+
if(ignore.indexOf(key)!==-1||key.match(/^__/)){
21+
continue;
3022
}
23+
// value = globalObj[key];
24+
25+
// key may be an invalid variable name (e.g. 'a-b')
26+
try{
27+
// eval('var ' + key);
28+
src+=`var${key} = global.${key};`;
29+
}catch(e){}
30+
}
3131

32-
returnsrc;
32+
returnsrc;
3333
}
3434

3535
module.exports=getImportGlobalsSrc;

‎lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var fileExists = require('./fileExists');
1111
*/
1212
functionrewire(filename){
1313
// is not a node_module path
14-
if(!filename.match(/^[a-zA-Z\_]/)){
14+
if(!filename.match(/^[a-zA-Z\_]/)||filename.match(/^[A-Z]:)){
1515
if(!fileExists(filename)){
1616
// create a __get__ mock to prevent tests breaking
1717
// when file does not exist

‎lib/rewire.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
constModule=require('module');
3-
const{ readFileSync, join}=require('fs');
3+
const{ readFileSync}=require('fs');
44
constgetImportGlobalsSrc=require('./getImportGlobalsSrc');
55
constgetDefinePropertySrc=require('./getDefinePropertySrc');
66
constmoduleEnv=require('./moduleEnv');
@@ -21,7 +21,7 @@ function internalRewire(parentModulePath, targetPath) {
2121
}
2222

2323
// Resolve full filename relative to the parent module
24-
targetPath=join(targetPath,parentModulePath);
24+
targetPath=Module._resolveFilename(targetPath,parentModulePath);
2525

2626
src=readFileSync(targetPath,'utf8');
2727

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"rewire-coderoad",
3-
"version":"3.1.3",
3+
"version":"3.1.4",
44
"description":"CodeRoad implementation to override 'require' in order to test globals",
55
"keywords": [
66
"coderoad",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp