1
1
"use strict" ;
2
2
var path = require ( 'path' ) ;
3
- var exists_1 = require ( './exists' ) ;
4
- function setGlobals ( config ) {
3
+ var exists_1 = require ( '../../services/exists' ) ;
4
+ function setDir ( ) {
5
+ if ( atom . project . rootDirectories . length > 0 ) {
6
+ return atom . project . rootDirectories [ 0 ] . path ;
7
+ }
8
+ else {
9
+ return null ;
10
+ }
11
+ }
12
+ exports . setDir = setDir ;
13
+ function setWin ( ) {
14
+ return navigator . appVersion . indexOf ( 'Win' ) > - 1 ;
15
+ }
16
+ exports . setWin = setWin ;
17
+ function setGlobals ( packageJson ) {
5
18
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 || { }
19
+ tutorial :packageJson . name ,
20
+ suffix :packageJson . config . testSuffix . substring ( packageJson . config . testSuffix . lastIndexOf ( '.' ) + 1 , packageJson . config . testSuffix . length ) ,
21
+ tutorialDir :path . join ( window . coderoad . dir , 'node_modules' , packageJson . name , packageJson . config . testDir ) ,
22
+ testRunner :packageJson . config . testRunner ,
23
+ testRunnerOptions :packageJson . config . testRunnerOptions || { }
11
24
} ) ;
12
- loadRepo ( config ) ;
13
- loadRunnerDep ( config ) ;
25
+ loadRepo ( packageJson ) ;
26
+ loadRunnerDep ( packageJson ) ;
14
27
}
15
28
exports . setGlobals = setGlobals ;
16
- function loadRunnerDep ( config ) {
17
- var flatDep = path . join ( window . coderoad . dir , 'node_modules' , config . config . testRunner , 'package.json' ) ;
18
- var treeDep = path . join ( window . coderoad . dir , 'node_modules' , config . name , 'node_modules' , config . config . testRunner , 'package.json' ) ;
29
+ function loadRunnerDep ( packageJson ) {
30
+ var flatDep = path . join ( window . coderoad . dir , 'node_modules' , packageJson . config . testRunner , 'package.json' ) ;
31
+ var treeDep = path . join ( window . coderoad . dir , 'node_modules' , packageJson . name , 'node_modules' , packageJson . config . testRunner , 'package.json' ) ;
19
32
var runnerMain ;
20
33
var runnerRoot ;
21
34
if ( exists_1 . fileExists ( flatDep ) ) {
@@ -42,16 +55,16 @@ function loadRunnerDep(config) {
42
55
window . coderoad . runner = require ( pathToMain ) ;
43
56
}
44
57
}
45
- function loadRepo ( config ) {
46
- if ( config . bugs && config . bugs . url ) {
47
- window . coderoad . issuesPath = config . bugs . url ;
58
+ function loadRepo ( packageJson ) {
59
+ if ( packageJson . bugs && packageJson . bugs . url ) {
60
+ window . coderoad . issuesPath = packageJson . bugs . url ;
48
61
}
49
- if ( config . repo && config . repo . url ) {
50
- var repo = config . repo . url ;
62
+ if ( packageJson . repo && packageJson . repo . url ) {
63
+ var repo = packageJson . repo . url ;
51
64
if ( ! ! repo . match ( / \. g i t $ / ) ) {
52
65
repo = repo . slice ( 0 , repo . length - 4 ) ;
53
66
}
54
67
window . coderoad . repo = repo ;
55
68
}
56
- window . coderoad . edit = config . config . edit && ! ! window . coderoad . repo || false ;
69
+ window . coderoad . edit = packageJson . config . edit && ! ! window . coderoad . repo || false ;
57
70
}