11"use strict" ;
22var 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 ) {
518window . 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 || { }
1124} ) ;
12- loadRepo ( config ) ;
13- loadRunnerDep ( config ) ;
25+ loadRepo ( packageJson ) ;
26+ loadRunnerDep ( packageJson ) ;
1427}
1528exports . 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' ) ;
1932var runnerMain ;
2033var runnerRoot ;
2134if ( exists_1 . fileExists ( flatDep ) ) {
@@ -42,16 +55,16 @@ function loadRunnerDep(config) {
4255window . coderoad . runner = require ( pathToMain ) ;
4356}
4457}
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 ;
4861}
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 ;
5164if ( ! ! repo . match ( / \. g i t $ / ) ) {
5265repo = repo . slice ( 0 , repo . length - 4 ) ;
5366}
5467window . coderoad . repo = repo ;
5568}
56- window . coderoad . edit = config . config . edit && ! ! window . coderoad . repo || false ;
69+ window . coderoad . edit = packageJson . config . edit && ! ! window . coderoad . repo || false ;
5770}