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

Commit4dee5c3

Browse files
committed
windows path fix
1 parentc016bc4 commit4dee5c3

File tree

9 files changed

+9
-49
lines changed

9 files changed

+9
-49
lines changed

‎lib/importPaths.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22
varpath_1=require('path');
3-
varsystem_1=require('./system');
43
varimportPathRegex=/require\(["'](BASE.+)["']\)([a-zA-Z0-9\-\_]+)?|^import.+?\s?["'](BASE.+)["'];?$/m;
54
varrelativePathRegex=/^BASE/;
65
functionfixImportPaths(_a){
@@ -12,14 +11,8 @@ function fixImportPaths(_a) {
1211
}
1312
varimportPath=isMatch[1]||isMatch[2]||isMatch[3];
1413
if(importPath.match(relativePathRegex)){
15-
varnewPath=void0;
16-
if(system_1.isWindows){
17-
newPath=path_1.join(dir,importPath.replace('BASE',''))
18-
.split('\\').join('\\\\');
19-
}
20-
else{
21-
newPath=path_1.join(dir,importPath.replace('BASE',''));
22-
}
14+
varnewPath=path_1.join(dir,importPath.replace('BASE',''))
15+
.split('\\').join('\\\\');
2316
returnline.replace(importPath,newPath);
2417
}
2518
returnline;

‎lib/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
"use strict";
22
varimportPaths_1=require('./importPaths');
3-
varsystem_1=require('./system');
43
varjsCodeRoad=function(_a){
54
vardir=_a.dir,content=_a.content;
6-
if(system_1.isWindows){
7-
dir=dir.split('\\').join('\\\\');
8-
}
5+
dir=dir.split('\\').join('\\\\');
96
return"(function(){'use strict';\nrequire('babel-register')({plugins:[\n ['transform-es2015-modules-commonjs',{loose:true,sourceRoot:'"+dir+"'}]\n]});\n"+require('process-console-log').logger+"\nconst _f_e = require('node-file-exists').default;\nconst _join = require('path').join;\nfunction exists(p) { return _f_e(_join('"+dir+"',p)); }\nrequire = require('rewire-coderoad');\n\n"+importPaths_1.default({dir:dir,content:content})+"\n\n}());";
107
};
118
Object.defineProperty(exports,"__esModule",{value:true});

‎lib/system.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"js-coderoad",
3-
"version":"0.1.4",
3+
"version":"0.1.5",
44
"description":"bundled javascript features for coderoad test runners",
55
"keywords": [
66
"coderoad",
@@ -33,7 +33,7 @@
3333
"babel-register":"^6.14.0",
3434
"node-file-exists":"^1.1.0",
3535
"process-console-log":"^0.2.5",
36-
"rewire-coderoad":"^3.1.3"
36+
"rewire-coderoad":"^3.1.4"
3737
},
3838
"devDependencies": {
3939
"ava":"^0.16.0",

‎src/importPaths.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import{join}from'path';
2-
import{isWindows}from'./system';
32

43
/*
54
import paths won't match the context of the test runner
@@ -24,18 +23,9 @@ export default function fixImportPaths({dir, content}): string {
2423

2524
// is a relative path
2625
if(importPath.match(relativePathRegex)){
27-
letnewPath;
28-
29-
if(isWindows){
30-
// fix buggy Windows paths
31-
// note: necessary to split and join before newPath is set to
32-
// a variable or backslashes are interpreted as escaped characters
33-
newPath=join(dir,importPath.replace('BASE',''))
34-
.split('\\').join('\\\\');
35-
}else{
36-
newPath=join(dir,importPath.replace('BASE',''));
37-
}
38-
26+
letnewPath=join(dir,importPath.replace('BASE',''))
27+
// fix windows paths
28+
.split('\\').join('\\\\');
3929
returnline.replace(importPath,newPath);
4030
}
4131
// no match, return line

‎src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
importfixImportPathsfrom'./importPaths';
2-
import{isWindows}from'./system';
32

43
constjsCodeRoad=({dir, content})=>{
54

65
// fix Windows paths
7-
if(isWindows){
8-
dir=dir.split('\\').join('\\\\');
9-
}
6+
dir=dir.split('\\').join('\\\\');
107

118
return`(function(){'use strict';
129
require('babel-register')({plugins:[

‎src/system.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎test/system.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"files": [
1919
"src/importPaths.ts",
2020
"src/index.ts",
21-
"src/system.ts",
2221
"src/typings/chai/chai.d.ts",
2322
"src/typings/cr/cr.d.ts",
2423
"src/typings/cr/globals.d.ts",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp