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

Commite7f12ef

Browse files
committed
object.values polyfill
1 parentdd7b94b commite7f12ef

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

‎src/services/set-globals.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import*aspathfrom'path';
2+
import{fileExists}from'./exists';
3+
4+
exportfunctionsetGlobals(config:PackageJson){
5+
window.coderoad=Object.assign(window.coderoad,{
6+
tutorial:config.name,
7+
suffix:config.config.testSuffix.substring(config.config.testSuffix.lastIndexOf('.')+1,config.config.testSuffix.length),
8+
tutorialDir:path.join(window.coderoad.dir,'node_modules',config.name,config.config.testDir),
9+
testRunner:config.config.testRunner,
10+
testRunnerOptions:config.config.testRunnerOptions||{}
11+
});
12+
// issues, bugs
13+
loadRepo(config);
14+
// set PackageDeps
15+
loadRunnerDep(config);
16+
}
17+
18+
functionloadRunnerDep(config:PackageJson){
19+
// test runner dir
20+
letflatDep=path.join(window.coderoad.dir,'node_modules',config.config.testRunner,'package.json');
21+
lettreeDep=path.join(window.coderoad.dir,'node_modules',config.name,'node_modules',config.config.testRunner,'package.json');
22+
23+
varrunnerMain;
24+
varrunnerRoot;
25+
if(fileExists(flatDep)){
26+
runnerMain=require(flatDep).main;
27+
runnerRoot=flatDep;
28+
}elseif(fileExists(treeDep)){
29+
runnerMain=require(treeDep).main;
30+
runnerRoot=treeDep;
31+
}else{
32+
letmessage='Error loading test runner. Post an issue. https://github.com/coderoad/atom-coderoad/issues';
33+
console.log(message);
34+
throwmessage;
35+
}
36+
37+
// fix main path for Windows
38+
letslash=window.coderoad.win ?'\\' :'/';
39+
runnerMain=path.join.apply(null,runnerMain.split(slash));
40+
// trim root path to folder
41+
runnerRoot=runnerRoot.substring(0,runnerRoot.lastIndexOf(slash));
42+
43+
letpathToMain=path.join(runnerRoot,runnerMain);
44+
45+
if(!!require(pathToMain).default){
46+
window.coderoad.runner=require(pathToMain).default;
47+
}else{
48+
window.coderoad.runner=require(pathToMain);
49+
}
50+
}
51+
52+
functionloadRepo(config){
53+
if(config.bugs&&config.bugs.url){
54+
window.coderoad.issuesPath=config.bugs.url;
55+
}
56+
if(config.repo&&config.repo.url){
57+
letrepo:string=config.repo.url;
58+
if(!!repo.match(/\.git$/)){
59+
repo=repo.slice(0,repo.length-4);
60+
}
61+
window.coderoad.repo=repo;
62+
}
63+
64+
window.coderoad.edit=config.config.edit&&!!window.coderoad.repo||false;
65+
}

‎src/typings/cr/globals.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface PackageJson {
1212

1313
interfaceObjectConstructor{
1414
assign(target:any, ...sources:any[]):any;
15+
values(obj:Object):any[];
1516
}
1617

1718
interfaceIntrinsicAttributes{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp